{"id":26319011,"url":"https://github.com/newmo-oss/gotestingmock","last_synced_at":"2026-03-04T20:05:54.475Z","repository":{"id":266192773,"uuid":"897317749","full_name":"newmo-oss/gotestingmock","owner":"newmo-oss","description":"gotestingmock mocking utilities for unit test in Go","archived":false,"fork":false,"pushed_at":"2025-03-07T02:54:04.000Z","size":14,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-07T03:28:11.619Z","etag":null,"topics":["golang","testing"],"latest_commit_sha":null,"homepage":"","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/newmo-oss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-02T12:27:51.000Z","updated_at":"2025-03-07T02:53:55.000Z","dependencies_parsed_at":"2024-12-08T16:47:57.582Z","dependency_job_id":null,"html_url":"https://github.com/newmo-oss/gotestingmock","commit_stats":null,"previous_names":["newmo-oss/gotestingmock"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fgotestingmock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fgotestingmock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fgotestingmock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fgotestingmock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newmo-oss","download_url":"https://codeload.github.com/newmo-oss/gotestingmock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746243,"owners_count":20341204,"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":["golang","testing"],"created_at":"2025-03-15T15:17:16.439Z","updated_at":"2026-03-04T20:05:54.468Z","avatar_url":"https://github.com/newmo-oss.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gotestingmock [![Go Reference](https://pkg.go.dev/badge/github.com/newmo-oss/gotestingmocko.svg)](https://pkg.go.dev/github.com/newmo-oss/gotestingmock)[![Go Report Card](https://goreportcard.com/badge/github.com/newmo-oss/gotestingmock)](https://goreportcard.com/report/github.com/newmo-oss/gotestingmock)\n\ngotestingmock mocking utilities for unit test in Go.\n\n## Usage\n\n### Running test functions on isolated goroutine with gotestingmock.Run\n\n```go\nfunc Test(t *testing.T) {\n\tt.Parallel()\n\n\t// gotestingmock.Run simulates a test function on a goroutine.\n\tgot := gotestingmock.Run(func(tb *gotestingmock.TB) {\n\t\t// The test helper can use *gotestingmock.TB as testing.TB\n\t\t// which is implemented  by testing.T, testing.B and testing.F.\n\t\tMyTestHelper(tb, \"arg1\")\n\t})\n\n\t// Check if the test helper failed with t.Error, t.Fatal or similar methods.\n\tif !got.Failed {\n\t\tt.Error(\"expected failed did not occur\")\n\t}\n\n\t// Check that the test helper has panicked.\n\tif got.PanicValue != nil {\n\t\tt.Error(\"unexpected panic:\", got.PanicValue)\n\t}\n}\n```\n\n### Detecting incorrect FailNow usage in goroutines with gotestingmock.StrictGoexit\n\n```go\nfunc TestWithHTTPServer(t *testing.T) {\n\ttb := gotestingmock.StrictGoexit(t)\n\n\tserver := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// This will panic because it's called from the handler's goroutine\n\t\t// tb.Fatal(\"unexpected error\")\n\n\t\t// Instead, use proper error handling:\n\t\tif err := someOperation(); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tw.WriteHeader(http.StatusOK)\n\t}))\n\tdefer server.Close()\n\n\tresp, err := http.Get(server.URL)\n\tif err != nil {\n\t\ttb.Fatal(err)  // This is safe - called from test goroutine\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\ttb.Fatalf(\"expected status 200, got %d\", resp.StatusCode)\n\t}\n}\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmo-oss%2Fgotestingmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewmo-oss%2Fgotestingmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmo-oss%2Fgotestingmock/lists"}