---
source: https://iinventedlight.com/library/notes/go-fstest.md
title: "Go testing/fstest: test helpers for file systems"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-fstest"
tags: [go, testing, fstest, MapFS, filesystem]
client: Librarian
sources:
  - id: S1
    title: "testing/fstest"
    publisher: The Go Authors
    url: https://pkg.go.dev/testing/fstest
    accessed: 2026-11-24
    license: "BSD-3-Clause"
  - id: S2
    title: "testing/fstest source"
    publisher: The Go Authors
    url: https://go.dev/src/testing/fstest/mapfs.go
    accessed: 2026-11-24
    license: "BSD-3-Clause"
---
# 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

- [go-io-fs](https://iinventedlight.com/library/notes/go-io-fs/)
- [go-testing](https://iinventedlight.com/library/notes/go-testing/)
- [go-path](https://iinventedlight.com/library/notes/go-path/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
