{"id":18519643,"url":"https://github.com/kyuff/testdata","last_synced_at":"2025-08-26T22:04:30.943Z","repository":{"id":222847524,"uuid":"758506996","full_name":"kyuff/testdata","owner":"kyuff","description":"Library to generate random and typed data for tests","archived":false,"fork":false,"pushed_at":"2025-02-16T21:03:59.000Z","size":33,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T22:18:16.489Z","etag":null,"topics":["generator","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/kyuff.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-16T13:24:42.000Z","updated_at":"2025-02-16T21:04:01.000Z","dependencies_parsed_at":"2024-02-16T15:55:27.993Z","dependency_job_id":"73764037-5329-4895-b6ed-033a80cffa62","html_url":"https://github.com/kyuff/testdata","commit_stats":null,"previous_names":["kyuff/testdata"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Ftestdata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Ftestdata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Ftestdata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyuff%2Ftestdata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyuff","download_url":"https://codeload.github.com/kyuff/testdata/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239236664,"owners_count":19604912,"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":["generator","golang","testing"],"created_at":"2024-11-06T17:16:59.696Z","updated_at":"2025-02-17T05:12:45.234Z","avatar_url":"https://github.com/kyuff.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testdata generator for Go\n\n[![Build Status](https://github.com/kyuff/testdata/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/kyuff/testdata/actions/workflows/go.yml)\n[![Report Card](https://goreportcard.com/badge/github.com/kyuff/testdata)](https://goreportcard.com/report/github.com/kyuff/testdata/)\n[![Go Reference](https://pkg.go.dev/badge/github.com/kyuff/testdata.svg)](https://pkg.go.dev/github.com/kyuff/testdata)\n[![codecov](https://codecov.io/gh/kyuff/testdata/graph/badge.svg?token=HRK7MBJHFN)](https://codecov.io/gh/kyuff/testdata)\n\nLibrary to generate random and typed data for tests.\n\n## Use case\n\nIn some types of tests it is convenient to randomize input data in order to avoid a hidden reliance on specific values.\nEspecially in code bases that model domain specific values using named types, this can be cumbersome to do by hand.\n\nThis library provides a simple and convenient way to configure value types and generate them for specific tests.\n\n## FAQ\n\n### Can I reuse a `testdata.Config` between tests?\n\nYes! There is even a convenient `testdata.DefaultConfig` you can use.\nYou can configure the default config using the convenient testdata.Values functions. Alternatively you can use options\nthat is prefixed using `With` when setting up your own `Config`.\n\n### Is it ok to use `testdata.Make()`?\n\nYes, the `testdata.MakeWith()` is only meant if you don't want to use the default config.\n\n### Can I control how values are generated?\n\nYes, use the option `testdata.WithGenerator` which accepts a func that provides a specific type. This func will be\ncalled each time there is a need to generate that specific type. This is a method to override the default generator.\n\n## Example\n\n````go\n\tvar (\n\t\tt = \u0026testing.T{}\n\t\t_ = testdata.MakeSticky[City](t)\n\t\ta = testdata.Make[Person](t)\n\t\tb = testdata.Make[Person](t, func(person Person) Person {\n\t\t\tperson.Age = 32\n\t\t\treturn person\n\t\t})\n\t)\n\n\tfmt.Printf(\"A: %#v\\n\", a)\n\tfmt.Printf(\"B: %#v\\n\", b)\n\n\t// Output:\n\t// A: testdata_test.Person{Name:\"My own name: 73\", Age:50, Dish:\"SPAGHETTI\", City:\"City-LCMNe2ur8bFrW7oM\", Note:\"string-k3Dc1kHJPXsAFv0C\"}\n\t// B: testdata_test.Person{Name:\"My own name: 94\", Age:32, Dish:\"SPAGHETTI\", City:\"City-LCMNe2ur8bFrW7oM\", Note:\"string-nUQnH3DqWyTPPTEi\"}\n````\n\nFind more detailed examples [here](example_make_test.go) and [here](example_makewith_test.go).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyuff%2Ftestdata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyuff%2Ftestdata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyuff%2Ftestdata/lists"}