{"id":26241156,"url":"https://github.com/solrac97gr/go-test-tables","last_synced_at":"2025-07-12T02:10:29.950Z","repository":{"id":162106831,"uuid":"636717701","full_name":"solrac97gr/go-test-tables","owner":"solrac97gr","description":"Example of Test Tables for new blog Article. 🧪","archived":false,"fork":false,"pushed_at":"2023-05-13T03:27:41.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T13:14:32.460Z","etag":null,"topics":["go","golang","testing","tests"],"latest_commit_sha":null,"homepage":"","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/solrac97gr.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-05T13:35:39.000Z","updated_at":"2023-05-05T13:36:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4ad2d1e-d3d1-4643-830e-817e0e1bfdb7","html_url":"https://github.com/solrac97gr/go-test-tables","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrac97gr%2Fgo-test-tables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrac97gr%2Fgo-test-tables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrac97gr%2Fgo-test-tables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrac97gr%2Fgo-test-tables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solrac97gr","download_url":"https://codeload.github.com/solrac97gr/go-test-tables/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243365981,"owners_count":20279276,"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":["go","golang","testing","tests"],"created_at":"2025-03-13T08:19:39.782Z","updated_at":"2025-03-13T08:19:41.696Z","avatar_url":"https://github.com/solrac97gr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to work with Test Tables and Mocks in Go\n\nFor this example we will use 2 external packages:\n\n-gomock\n-testify/assert\n\n## Mocks\n\nFor the mocks I use gomock. It is a mock framework for Go. It integrates well with Go's built-in testing package, but can be used in other contexts too.\n\nYou can see in the file generate-mocks.sh how to generate the mocks.\n\n## Test Tables\n\nFor the test tables I use a `map[string]struct{}` with the key being the name of the test and the value being a `struct{}`.\n\nInside of the struct we add all the external information we will need like parameters.\n\nWe also add there 2 functions:\n\n- testSetup: This function will be called before the test is run. It will setup the behavior of the mocks and the test data.\n\n- assertSetup: This function will be called before the test is run. It will setup the mocks and the test data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolrac97gr%2Fgo-test-tables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolrac97gr%2Fgo-test-tables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolrac97gr%2Fgo-test-tables/lists"}