{"id":15651379,"url":"https://github.com/caarlos0/testfs","last_synced_at":"2025-04-28T15:58:12.268Z","repository":{"id":49417422,"uuid":"336085698","full_name":"caarlos0/testfs","owner":"caarlos0","description":"A simple fs.FS implementation to be used inside tests.","archived":false,"fork":false,"pushed_at":"2023-06-14T13:38:05.000Z","size":23,"stargazers_count":33,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T20:42:00.274Z","etag":null,"topics":["filesystem","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/caarlos0.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":"2021-02-04T21:21:26.000Z","updated_at":"2023-12-23T18:39:34.000Z","dependencies_parsed_at":"2024-06-18T20:08:57.413Z","dependency_job_id":null,"html_url":"https://github.com/caarlos0/testfs","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarlos0%2Ftestfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarlos0%2Ftestfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarlos0%2Ftestfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caarlos0%2Ftestfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caarlos0","download_url":"https://codeload.github.com/caarlos0/testfs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246308049,"owners_count":20756479,"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":["filesystem","golang","testing"],"created_at":"2024-10-03T12:38:09.469Z","updated_at":"2025-03-31T11:31:12.320Z","avatar_url":"https://github.com/caarlos0.png","language":"Go","readme":"# testfs\n\nA simple `fs.FS` which is contained in a test (using `testing.TB`'s `TempDir()`)\nand with a few helper methods.\n\nPS: This lib only works on Go 1.16+.\n\n## Example\n\n```go\nfunc TestSomething(t *testing.T) {\n\ttmpfs := testfs.New(t)\n\ttestfile := \"foo/bar/foobar\"\n\t_ = tmpfs.MkdirAll(filepath.Dir(testfile), 0o764)\n\t_ = tmpfs.WriteFile(testfile, []byte(\"example\"), 0o644)\n\n\t// you can now use tmpfs as a fs.FS...\n\t// fs.WalkDir(tmpfs, \".\", func(path string, d fs.DirEntry, err error) error { return nil })\n\n\t// and read files of course:\n\tbts, _ := fs.ReadFile(tmpfs, testfile)\n\tfmt.Println(string(bts))\n}\n```\n\n## Why\n\nThe idea is to able to test code that use a `fs.FS`, without having to,\nfor example, commit a bunch of files inside `testdata` and without using\nin-memory implementation that might not do the same thing as a real FS.\n\nThis is a real FS, it only limits itself to a temporary directory and\ncleans after itself once the test is done. You also get a couple of helper\nmethods to create the structure you need.\n\n## Other options\n\nIf you don't mind testing against an in-memory implementation, the native\n`fstest.MemFS` is a good option.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaarlos0%2Ftestfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaarlos0%2Ftestfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaarlos0%2Ftestfs/lists"}