testerfs

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS struct {
	// contains filtered or unexported fields
}

func New

func New(underlying fs.FS) (*FS, error)

New returns a new testerfs.FS that wraps the given fs.FS. The returned testerfs.FS will only persist changes in-memory, and it will be possible to diff the changes made to the testerfs.FS against the "expected" file contents for each corresponding file in the test fixture.

func NewWithFileMask

func NewWithFileMask(underlying fs.FS, paths ...string) (*FS, error)

NewWithFileMask returns a new testerfs.FS that wraps the given fs.FS. The returned testerfs.FS will only cover files from the underlying FS that are present in the given paths. This is useful for testing a specific subset of a larger test fixture.

func NewWithLogger

func NewWithLogger(underlying fs.FS, logger *slog.Logger) (*FS, error)

NewWithLogger does the same thing as calling New, but injects a logger for observing noteworthy filesystem activity.

func NewWithRoot

func NewWithRoot(root string) (*FS, error)

func (*FS) Create

func (fsys *FS) Create(name string) (rwfs.File, error)

Create helps implement the rwfs.FS interface. The new file is persisted only in-memory, and will serve as the "actual" contents for the given path.

func (*FS) Diff

func (fsys *FS) Diff(name string) string

Diff returns a human-readable diff between the expected and actual contents for the given file path. If there is no diff, an empty string is returned.

func (*FS) DiffAll

func (fsys *FS) DiffAll() string

DiffAll returns a human-readable diff for all files in the FS. If there are no diffs, an empty string is returned.

func (*FS) Open

func (fsys *FS) Open(name string) (fs.File, error)

Open implements fs.FS.

func (*FS) OpenAsWritable

func (fsys *FS) OpenAsWritable(name string) (rwfs.File, error)

OpenAsWritable implements rwfs.FS.

func (FS) ReadDir

func (fsys FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS.

func (*FS) Truncate

func (fsys *FS) Truncate(name string, n int64) error

Truncate implements rwfs.FS.

Jump to

Keyboard shortcuts

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