testfs

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileOperation

type FileOperation struct {
	Operation Operation
	Filename  string
}

type Filesystem

type Filesystem struct {
	Inner billy.Filesystem
	// contains filtered or unexported fields
}

A special filesystem that allows injecting errors at arbitrary operations.

func (*Filesystem) Chroot

func (f *Filesystem) Chroot(path string) (billy.Filesystem, error)

func (*Filesystem) Create

func (f *Filesystem) Create(filename string) (billy.File, error)

func (*Filesystem) Join

func (f *Filesystem) Join(elem ...string) string

func (*Filesystem) Lstat

func (f *Filesystem) Lstat(filename string) (os.FileInfo, error)

func (*Filesystem) MkdirAll

func (f *Filesystem) MkdirAll(filename string, perm os.FileMode) error

func (*Filesystem) Open

func (f *Filesystem) Open(filename string) (billy.File, error)

func (*Filesystem) OpenFile

func (f *Filesystem) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)

func (*Filesystem) ReadDir

func (f *Filesystem) ReadDir(path string) ([]os.FileInfo, error)
func (f *Filesystem) Readlink(link string) (string, error)

func (*Filesystem) Remove

func (f *Filesystem) Remove(filename string) error

func (*Filesystem) Rename

func (f *Filesystem) Rename(oldpath, newpath string) error

func (*Filesystem) Root

func (f *Filesystem) Root() string

func (*Filesystem) Stat

func (f *Filesystem) Stat(filename string) (os.FileInfo, error)
func (f *Filesystem) Symlink(target, link string) error

func (*Filesystem) TempFile

func (f *Filesystem) TempFile(dir, prefix string) (billy.File, error)

type Operation

type Operation int
const (
	NONE Operation = iota
	CREATE
	OPEN
	OPENFILE
	STAT
	RENAME
	REMOVE
	READDIR
	SYMLINK
	READLINK
	MKDIRALL
)

func (Operation) String

func (o Operation) String() string

type UsageCollector

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

UsageCollector tracks which file operations have been used in a test suite and reports which were not tested with an injected error.

func (*UsageCollector) UntestedOps

func (u *UsageCollector) UntestedOps() []FileOperation

func (*UsageCollector) WithError

func (uc *UsageCollector) WithError(fs billy.Filesystem, op Operation, filename string, err error) *Filesystem

Jump to

Keyboard shortcuts

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