{"id":37215684,"url":"https://github.com/recursionpharma/go-testutils","last_synced_at":"2026-01-15T00:56:35.749Z","repository":{"id":57491479,"uuid":"113240253","full_name":"recursionpharma/go-testutils","owner":"recursionpharma","description":"Golang helpers for testing","archived":false,"fork":false,"pushed_at":"2020-06-19T18:42:51.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":60,"default_branch":"trunk","last_synced_at":"2024-06-20T11:59:53.212Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/recursionpharma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-05T22:33:16.000Z","updated_at":"2024-06-20T11:59:53.212Z","dependencies_parsed_at":"2022-08-30T04:00:26.225Z","dependency_job_id":null,"html_url":"https://github.com/recursionpharma/go-testutils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/recursionpharma/go-testutils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recursionpharma%2Fgo-testutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recursionpharma%2Fgo-testutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recursionpharma%2Fgo-testutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recursionpharma%2Fgo-testutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recursionpharma","download_url":"https://codeload.github.com/recursionpharma/go-testutils/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recursionpharma%2Fgo-testutils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28440977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"ssl_error","status_checked_at":"2026-01-15T00:55:20.945Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-15T00:56:35.154Z","updated_at":"2026-01-15T00:56:35.741Z","avatar_url":"https://github.com/recursionpharma.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![scorecard-score](https://github.com/recursionpharma/octo-guard-badges/blob/trunk/badges/repo/go-testutils/maturity_score.svg?raw=true)](https://infosec-docs.prod.rxrx.io/octoguard/scorecards/go-testutils)\n[![scorecard-status](https://github.com/recursionpharma/octo-guard-badges/blob/trunk/badges/repo/go-testutils/scorecard_status.svg?raw=true)](https://infosec-docs.prod.rxrx.io/octoguard/scorecards/go-testutils)\n# go-testutils\n\nGolang helpers for testing.\n\n*NOTE* This is a public repo.\n\n## Collection Assertions\n\nThis repository includes several new assertions: `Any`, `All`, `None`, `AtLeast`, `AtMost`, and `Exactly`. These can be wrapped around existing assertions to perform the assertion on every element of a collection.\n\nExample:\n\n```golang\nSo([]int{1, 2, 3, 4}, Any(ShouldEqual), 4)\nSo([]int{1, 2, 3, 4}, Exactly(2, ShouldBeLessThan), 3)\n```\nThis lets you perform an assertion on a collection without making assumptions regarding the order of the elements. For example:\n\n```golang\nSo(printings, Any(ShouldHaveId), id)\n```\n\nYou may not want to write many different complex assertions like `ShouldHaveNameAndIdAndAddressAndBlah` to test multiple properties of a single collection element together, so the utility `JoinComparisons` can be used to construct these for you. For example:\n\n```golang\ntype testStruct struct {\n  Name string\n  Id   int\n}\n\ntestSlice := []testStruct{\n  testStruct{\n    Name: \"Alice\",\n    Id:   1,\n  },\n  testStruct{\n    Name: \"Bob\",\n    Id:   2,\n  },\n}\n\nSo(testSlice, Exactly(1, func(actual interface{}, expected ...interface{}) string {\n  return JoinComparisons([]string{\n    ShouldEqual(actual.(testStruct).Name, \"Alice\"),\n    ShouldEqual(actual.(testStruct).Id, 1),\n  })\n}))\n\nSo(testSlice, Exactly(1, func(actual interface{}, expected ...interface{}) string {\n  return JoinComparisons([]string{\n    ShouldEqual(actual.(testStruct).Name, \"Bob\"),\n    ShouldEqual(actual.(testStruct).Id, 2),\n  })\n}))\n```\n\n## Other Assertions\n\nContains custom assertions that work with [goconvey](https://github.com/smartystreets/goconvey).\n\nFor example, if we have some code that returns an error:\n```golang\npackage thehulk\n\nimport (\n\t\"fmt\"\n)\n\ntype Hulk struct {\n\tisHulked bool\n}\n\nfunc (h *Hulk) Hulkify(angerLevel int) error {\n\tif angerLevel \u003c 3 {\n\t\treturn fmt.Errorf(\"Not angry enough: %d\", angerLevel)\n\t}\n\th.isHulked = true\n\treturn nil\n}\n```\nWe might test it like this:\n```golang\npackage thehulk_test\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\n\t. \"github.com/smartystreets/goconvey/convey\"\n\t. \"github.com/recursionpharma/go-testutils/assertions\"\n)\n\nfunc TestHulkify (t *testing.T) {\n\tt.Parallel()\n\n\tConvey(\"Given an anger level\", t, func() {\n\n\t\tConvey(\"If the anger is too low, an error should be returned\", func() {\n\t\t\tangerLevel := 2\n\t\t\terr := h.Hulkify(angerLevel)\n\t\t\tSo(err, ShouldHaveErrorMessageWithSubstring, fmt.Sprintf(\"%d\", angerLevel))\n\t\t})\n\n\t\tConvey(\"If the anger is high enough, no error should be returned\", func() {\n\t\t\terr := h.Hulkify(5)\n\t\t\tSo(err, ShouldBeNil)\n\t\t})\n\t})\n}\n```\n\n## This repo\n\n    go-testutils/\n    |-- assertions/\n    |   contains custom assertions that work with goconvey\n    |-- .editorconfig\n    |   configures default for displaying files (e.g. in github PRs)\n    |-- .gitignore\n    |   git ignored files\n    |-- Gopkg.lock\n    |   go dep file\n    |-- Gopkg.toml\n    |   go dep file\n    |-- README.md\n    |   this file\n    `-- .travis.yml\n        travis configuration\n\nThe above file tree was generated with `tree -a -F -L 1 --charset ascii`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecursionpharma%2Fgo-testutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecursionpharma%2Fgo-testutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecursionpharma%2Fgo-testutils/lists"}