{"id":14557452,"url":"https://github.com/raphoester/chaos","last_synced_at":"2026-01-12T06:39:17.716Z","repository":{"id":255446852,"uuid":"852267784","full_name":"raphoester/chaos","owner":"raphoester","description":"A simple library for generating deterministic chaotic values.","archived":false,"fork":false,"pushed_at":"2024-09-06T15:04:12.000Z","size":77,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-07T07:08:12.006Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raphoester.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":"2024-09-04T14:15:07.000Z","updated_at":"2024-09-06T15:04:16.000Z","dependencies_parsed_at":"2024-09-05T07:07:37.470Z","dependency_job_id":"a197e2e1-94a5-4f6f-aed0-402913f3d161","html_url":"https://github.com/raphoester/chaos","commit_stats":null,"previous_names":["raphoester/chaos"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphoester%2Fchaos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphoester%2Fchaos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphoester%2Fchaos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphoester%2Fchaos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raphoester","download_url":"https://codeload.github.com/raphoester/chaos/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231929873,"owners_count":18447579,"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":[],"created_at":"2024-09-06T20:01:16.615Z","updated_at":"2026-01-12T06:39:17.702Z","avatar_url":"https://github.com/raphoester.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Chaos - Stop hardcoding test values !\n \n**WARNING: This library is still in its early development phase (semver 0.x). Retrocompatibility is not ensured.**\n\n## Why Chaos ?\n\nLet's say that you want to write any kind of test.\nYou have to provide some input values to your function, and you have to check that the output is what you expect.\n\n```go \nfunc TestSaveUser(t *testing.T) {\n    repository := NewRepository()\n    if err := repository.SaveUser(\"John\", \"Doe\"); err != nil {\n        t.Errorf(\"error while saving user: %v\", err)\n    }\n}\n```\n\nDo you want to write \"John\" and \"Doe\" everywhere in your tests ?\n\n- What if you have to test a function that takes 10 parameters ?\n- What if you have to write 10 tests for this function ?\n- What if some of your tests require you to call this function multiple times ?\n\nHardcoded values cause pain.\n\n\"Why not use random values ?\" - you may say\n\nBut random values are not deterministic.\n\nUsing random values leads to what we call \"flaky\" tests.\n\nWith flaky tests, it will happen that you simply can't reproduce that bug that your CI found.\n\n## Chaos to the rescue\n\nChaos is a library that generates \"random\" (deterministic) values for you, and makes them reproducible.\n\n```go\nfunc TestSaveUser(t *testing.T) {\n    repository := NewRepository()\n\n    // generate a random string of length 10 with the default seed\n    firstName := chaos.String(10) \n    lastName := chaos.String(10)\n\t\n    if err := repository.SaveUser(firstName, lastName); err != nil {\n        t.Errorf(\"Error while saving user: %v\", err)\n    }\n}\n```\n\nUnlike your random seed (typically the current time), the hardcoded seed doesn't change between executions.\nThat means you will get the same values every single time.\n\n## Available Functions\n\nThere are many functions that allow you to generate different kinds of values: \n- Int\n- Float\n- Bool\n- Duration\n- UUID\n- Time\n- Slice items...\n\nFor detailed usage of each function, please refer to the source code and test files.\n\n## Contributing\n\nIf you'd like to contribute to Chaos, please follow these steps:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n### Running Tests\n\nTo run the tests for Chaos:\n\n1. Make sure you have Go installed on your system.\n2. Clone the repository:\n   ```bash\n   git clone https://github.com/your-username/chaos.git\n   cd chaos\n   ```\n3. Run the tests using the Makefile:\n   ```bash\n   make test\n   ```\n\nThis will run all the tests in the package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphoester%2Fchaos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraphoester%2Fchaos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphoester%2Fchaos/lists"}