{"id":16095548,"url":"https://github.com/meowgorithm/baby-blackbox","last_synced_at":"2025-04-05T20:14:04.481Z","repository":{"id":57586479,"uuid":"136962658","full_name":"meowgorithm/baby-blackbox","owner":"meowgorithm","description":"Blackbox testing for Go JSON APIs (and babies)","archived":false,"fork":false,"pushed_at":"2020-04-16T22:49:47.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-18T19:49:03.591Z","etag":null,"topics":["blackbox-testing","go","goji","testing"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/meowgorithm/baby-blackbox","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meowgorithm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-11T18:03:28.000Z","updated_at":"2024-05-16T15:24:54.000Z","dependencies_parsed_at":"2022-09-13T12:42:41.871Z","dependency_job_id":null,"html_url":"https://github.com/meowgorithm/baby-blackbox","commit_stats":null,"previous_names":["magicnumbers/blackbox","magicnumbers/baby-blackbox"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meowgorithm%2Fbaby-blackbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meowgorithm%2Fbaby-blackbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meowgorithm%2Fbaby-blackbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meowgorithm%2Fbaby-blackbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meowgorithm","download_url":"https://codeload.github.com/meowgorithm/baby-blackbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393573,"owners_count":20931813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blackbox-testing","go","goji","testing"],"created_at":"2024-10-09T17:06:23.683Z","updated_at":"2025-04-05T20:14:04.459Z","avatar_url":"https://github.com/meowgorithm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc Badge](https://godoc.org/github.com/meowgorithm/baby-blackbox?status.svg)](http://godoc.org/github.com/meowgorithm/baby-blackbox)\n\nBaby Blackbox\n=============\n\nBlackbox testing for Go JSON APIs. Currently, it supports the Go standard\nlibrary’s Multiplexer (`http.ServeMux`) and the [Goji][goji] multiplexer\n(`goji.Mux`). If there's another multiplexer you'd like it to support let us\nknow.\n\n[goji]: http://goji.io\n\n\n## Example\n\n```go\n\npackage main_test\n\nimport (\n    \"testing\"\n    blackbox \"github.com/meowgorithm/baby-blackbox\"\n    app \".\"\n)\n\ntype user struct {\n    ID int      `json:\"id,omitempty\"`\n    Name string `json:\"name\"`\n}\n\ntype apiError {\n    Code int       `json:\"code\"`\n    Message string `json:\"message\"`\n}\n\nfunc TestMain(m *testing.M) {\n    os.Exit(m.Run())\n}\n\nfunc TestStuff(t *testing.T) {\n\n    // Create a blackbox testing thing from your application's multiplexer\n    api := blackbox.New(t, app.GetMux())\n\n    // The payload we'll send in the next request\n    u := user{Name: \"Frankie\"}\n\n    // Create a user expecting to get an ID back in a JSON object. We assert\n    // that we want a 201 Created status code.\n    api.Request(\"POST\", \"/user\", u).\n        Created().\n        JSON(\u0026u)\n\n    // Make sure we got an ID in the response\n    if u.ID == 0 {\n        t.Error(\"expected to receive an ID, but we did not\")\n    }\n\n    var apiErr apiError\n\n    // Check another route, expecting a 401 Unauthorized error\n    api.Request(\"GET\", \"/cats\", nil).\n        Status(http.StatusUnauthorized).\n        JSON(\u0026apiErr)\n\n    if err.Code != 21 {\n        t.Errorf(\"thought we were gonna get error code 21, instead got %d\", err.Code)\n    }\n}\n\n```\n\nFor an example in the context of a more complete application, see the `example`\ndirectory.\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeowgorithm%2Fbaby-blackbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeowgorithm%2Fbaby-blackbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeowgorithm%2Fbaby-blackbox/lists"}