{"id":16056875,"url":"https://github.com/markbates/filetest","last_synced_at":"2025-07-04T23:08:41.286Z","repository":{"id":57487378,"uuid":"80668846","full_name":"markbates/filetest","owner":"markbates","description":"Test generated files","archived":false,"fork":false,"pushed_at":"2019-02-24T15:42:30.000Z","size":13,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T14:39:28.593Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markbates.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}},"created_at":"2017-02-01T22:00:45.000Z","updated_at":"2017-02-01T22:00:54.000Z","dependencies_parsed_at":"2022-09-01T23:02:36.901Z","dependency_job_id":null,"html_url":"https://github.com/markbates/filetest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markbates/filetest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Ffiletest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Ffiletest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Ffiletest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Ffiletest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markbates","download_url":"https://codeload.github.com/markbates/filetest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Ffiletest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263632057,"owners_count":23491530,"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-10-09T03:00:38.728Z","updated_at":"2025-07-04T23:08:41.264Z","avatar_url":"https://github.com/markbates.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# filetest\n\nDo a lot of file/code generation? Yeah, me too! And you know what I've noticed about it? It's a huge pain in the ass test! So how do I propose we go about it? Well, with this tool!\n\n```text\n$ go get -u github.com/markbates/filetest\n```\n\n## Usage\n\nThe most basic usage is to create a file called `filetest.json`. Really imaginative, isn't? Then fill it with a array of stuff you want to test.\n\n```json\n[{\n  \"path\": \"cmd/file.go\",\n  \"contains\": [\n    \"type File struct\"\n  ]\n}, {\n  \"path\": \"cmd/root.go\",\n  \"contains\": [\"pwd, _ = os.Getwd()\"]\n}]\n```\n\nThen just run:\n\n```\n$ filetest\n```\n\nThat's it!\n\n## More Complex Usage\n\nOk, so you want to make things more complex? OK, I hear you!\n\nUsing the `-c` flag you can point \"the tool\" at either a particalar `.json` file you want to use, or at a directory of `.json` files that it will use to run it's tests.\n\n```text\n$ filetest -c some/specific/file.json\n$ filetest -c some/rando/directory\n```\n\n## Fail Fast\n\nAshamed of all the failures you're getting and only want to see them 1 at a time? I get it, we all feel overwhelmed sometimes. The `-f` flag has your back.\n\n## Use Go and Want to Add These Tests to Your Test Suite?\n\nWell, you sure are a pushy one, but OK. You're in luck. This is a Go tool, so it's not hard. In fact, the tests for this tool USE THIS TOOL!! OMG!! INCEPTION!!!\n\n```go\npackage cmd\n\nimport (\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/require\"\n)\n\nfunc Test_Run(t *testing.T) {\n\tr := require.New(t)\n\terr := Run(\"../filetest.json\")\n\tr.NoError(err)\n}\n\nfunc Test_Run_with_Errors(t *testing.T) {\n\terrs = []error{}\n\tr := require.New(t)\n\terr := Run(\"./examples\")\n\tr.NoError(err)\n\tr.Len(errs, 2)\n}\n```\n\n## Match the Whole Darn Thing!\n\nOK, so by now you're saying, what if I want to make the entire file against a known file? What am I supposed to do copy and paste the whole darn thing into a JSON file? C'mon? First, let's take the tone down a bit, there's really no need for that type of langage. I'm trying to help, remember? All we need to do in that case is use the `equals_path` attribute in our JSON file to point at another file. Did I confuse you? Yeah, that's what I thought.\n\nHere's an example:\n\n```json\n[{\n  \"path\": \"../cmd/errors.go\",\n  \"equals_path\": \"../cmd/errors.go\"\n}, {\n  \"path\": \"../cmd/root.go\",\n  \"equals_path\": \"../cmd/root_test.go\"\n}]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Ffiletest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkbates%2Ffiletest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Ffiletest/lists"}