fakefs

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 11 Imported by: 0

Documentation

Overview

Package fakefs provides a fake file system implementation for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareFS added in v0.5.2

func PrepareFS(txt string, modifiers ...FileModifier) (scalibrfs.FS, error)

PrepareFS parses a txtar string into a mock filesystem. Optional modifiers can be provided to intercept and modify files (e.g., compression). Files ending in "/" in the txtar archive are treated as empty directories.

func SimLinkModifier added in v0.5.2

func SimLinkModifier(name string, f *fstest.MapFile) error

SimLinkModifier dynamically loads a file content from a specific location, example:

-- /path/to/file --
-> testdata/file

func TarGzModifier added in v0.5.2

func TarGzModifier(name string, f *fstest.MapFile) error

TarGzModifier parses the content of a .tar.gz file like a nested txtar and builds the tarball content, Example:

-- example.tar.gz --
== FILE1.ext ==
content
== FILE2.ext ==
content

Types

type FakeFileInfo

type FakeFileInfo struct {
	FileName    string
	FileSize    int64
	FileMode    fs.FileMode
	FileModTime time.Time
}

FakeFileInfo is a fake implementation of fs.FileInfo.

func (FakeFileInfo) IsDir

func (i FakeFileInfo) IsDir() bool

IsDir returns true if the file is a directory.

func (FakeFileInfo) ModTime

func (i FakeFileInfo) ModTime() time.Time

ModTime returns the modification time of the file.

func (FakeFileInfo) Mode

func (i FakeFileInfo) Mode() fs.FileMode

Mode returns the mode of the file.

func (FakeFileInfo) Name

func (i FakeFileInfo) Name() string

Name returns the name of the file.

func (FakeFileInfo) Size

func (i FakeFileInfo) Size() int64

Size returns the size of the file.

func (FakeFileInfo) Sys

func (i FakeFileInfo) Sys() any

Sys is an implementation of FileInfo.Sys() that returns nothing (nil).

type FileModifier added in v0.5.2

type FileModifier func(name string, f *fstest.MapFile) error

FileModifier allows mutating a file (e.g., compressing data, changing mode)

type MockEvalSymlinksFS added in v0.3.2

type MockEvalSymlinksFS struct {
	scalibrfs.FS

	Symlinks map[string]string
}

MockEvalSymlinksFS is a mock implementation of image.EvalSymlinksFS for testing.

func NewMockEvalSymlinksFS added in v0.3.2

func NewMockEvalSymlinksFS(fs scalibrfs.FS, symlinks map[string]string) *MockEvalSymlinksFS

NewMockEvalSymlinksFS creates a new MockEvalSymlinksFS.

func (fs *MockEvalSymlinksFS) EvalSymlink(name string) (string, error)

EvalSymlink mocks the evaluation of symlinks.

Jump to

Keyboard shortcuts

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