Help us shape the future of Go! Take the 2026 Go Developer Survey

fstest

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package fstest provides a contract test suite shared by every FileSystem implementation in go-bash. Each implementation invokes Run(t, Suite{...}) from its own _test.go to validate the common semantic subset.

The suite tests the operations enumerated in the spec: file CRUD, dir CRUD, rename, hard link, symlink, lstat, readlink, realpath, chmod, chtimes, mkdir recursive, rm recursive, walk — plus the path-safety invariants (null-byte rejection, traversal containment).

Implementations carry slightly different capabilities (e.g. read-only filesystems, or filesystems that disallow symlinks for security). The Suite struct lets each adapter declare which behaviors to test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, s Suite)

Run drives the full contract suite against the configured Factory.

Types

type Factory

type Factory func(t *testing.T) (gobashfs.FileSystem, func())

Factory builds a fresh FileSystem rooted at an isolated directory for each subtest. The cleanup func is called at the end of every subtest. If the implementation is purely in-memory, cleanup may be a no-op.

type Suite

type Suite struct {
	Name           string
	New            Factory
	SupportsSymlnk bool // implementation honors Symlink/Readlink/Lstat
	SupportsHardLn bool // implementation honors Link with shared content
	SupportsChmod  bool
	SupportsChtime bool
	// SandboxRoot, if non-empty, is the absolute path under which writes
	// land. Tests that exercise "/" semantics use SandboxRoot+"/x" instead.
	SandboxRoot string
}

Suite enumerates the optional capabilities an implementation can opt into. Tests guarded by a false flag are silently skipped.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL