Go testing/fstest: test helpers for file systems
Answer: Package fstest implements support for testing implementations and users of file systems.
TestFS
TestFS tests a file system implementation.
Otherwise a file system must contain at least the listed files, and it can also contain others.
It also checks that the file system contains at least the expected files.
The contents of the file system must not change concurrently with TestFS.
As a special case, if no expected files are listed, the file system must be empty.
MapFS in the source
A MapFS is a simple in-memory file system for use in tests.
Open opens the named file after following any symbolic links.
Lstat makes no attempt to follow the link.
A MapFile describes a single file in a MapFS.
See also
Claims
- id: C1 claim: Package fstest implements support for testing implementations and users of file systems. source: S1 evidence: "Package fstest implements support for testing implementations and users of file systems."
- id: C2 claim: TestFS tests a file system implementation. source: S1 evidence: "TestFS tests a file system implementation."
- id: C3 claim: The contents of the file system must not change concurrently with TestFS. source: S1 evidence: "The contents of fsys must not change concurrently with TestFS."
- id: C4 claim: Lstat makes no attempt to follow the link. source: S2 evidence: "Lstat makes no attempt to follow the link."
Sources
- [S1] testing/fstest. The Go Authors. https://pkg.go.dev/testing/fstest . License: BSD-3-Clause. Accessed 2026-11-24.
- [S2] testing/fstest source. The Go Authors. https://go.dev/src/testing/fstest/mapfs.go . License: BSD-3-Clause. Accessed 2026-11-24.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, testing/fstest; The Go Authors, testing/fstest source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, testing/fstest; The Go Authors, testing/fstest source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go testing/fstest: test helpers for file systems." iinventedlight Library, iil:note:chyw7ag0, version of 2026-11-24. https://iinventedlight.com/library/notes/go-fstest/. License: CC-BY-4.0.
@misc{iil_note_chyw7ag0,
author = {{iinventedlight}},
title = {{Go testing/fstest: test helpers for file systems}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/go-fstest/},
note = {Permanent ID iil:note:chyw7ag0. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-fstest.schema.json (schema; CC-BY-4.0)
- go-fstest.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-fstest.md.