mockfs

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mockfs implements in-memory filesystem for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Directory

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

Directory is mock in-memory implementation of fs.Directory.

func NewDirectory

func NewDirectory() *Directory

NewDirectory returns new mock directory.

func (*Directory) AddDir

func (imd *Directory) AddDir(name string, permissions os.FileMode) *Directory

AddDir adds a fake directory with a given name and permissions.

func (*Directory) AddDirDevice added in v0.8.0

func (imd *Directory) AddDirDevice(name string, permissions os.FileMode, deviceInfo fs.DeviceInfo) *Directory

AddDirDevice adds a fake directory with a given name and permissions.

func (*Directory) AddErrorEntry added in v0.8.0

func (imd *Directory) AddErrorEntry(name string, permissions os.FileMode, err error) *ErrorEntry

AddErrorEntry adds a fake directory with a given name and permissions.

func (*Directory) AddFile

func (imd *Directory) AddFile(name string, content []byte, permissions os.FileMode) *File

AddFile adds a mock file with the specified name, content and permissions.

func (*Directory) AddFileDevice added in v0.8.0

func (imd *Directory) AddFileDevice(name string, content []byte, permissions os.FileMode, deviceInfo fs.DeviceInfo) *File

AddFileDevice adds a mock file with the specified name, content, permissions, and device info.

func (*Directory) AddFileLines

func (imd *Directory) AddFileLines(name string, lines []string, permissions os.FileMode) *File

AddFileLines adds a mock file with the specified name, text content and permissions.

func (*Directory) Child added in v0.4.0

func (imd *Directory) Child(ctx context.Context, name string) (fs.Entry, error)

Child gets the named child of a directory.

func (*Directory) Device added in v0.8.0

func (e *Directory) Device() fs.DeviceInfo

func (*Directory) FailReaddir

func (imd *Directory) FailReaddir(err error)

FailReaddir causes the subsequent Readdir() calls to fail with the specified error.

func (*Directory) IsDir

func (e *Directory) IsDir() bool

func (*Directory) LocalFilesystemPath added in v0.8.0

func (e *Directory) LocalFilesystemPath() string

func (*Directory) ModTime

func (e *Directory) ModTime() time.Time

func (*Directory) Mode

func (e *Directory) Mode() os.FileMode

func (*Directory) Name

func (e *Directory) Name() string

func (*Directory) OnReaddir added in v0.6.0

func (imd *Directory) OnReaddir(cb func())

OnReaddir invokes the provided function on read.

func (*Directory) Owner

func (e *Directory) Owner() fs.OwnerInfo

func (*Directory) Readdir

func (imd *Directory) Readdir(ctx context.Context) (fs.Entries, error)

Readdir gets the contents of a directory.

func (*Directory) Remove

func (imd *Directory) Remove(name string)

Remove removes directory entry with a given name.

func (*Directory) Size

func (e *Directory) Size() int64

func (*Directory) Subdir

func (imd *Directory) Subdir(name ...string) *Directory

Subdir finds a subdirectory with a given name.

func (*Directory) Sys

func (e *Directory) Sys() interface{}

type ErrorEntry added in v0.8.0

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

ErrorEntry is mock in-memory implementation of fs.ErrorEntry.

func (*ErrorEntry) Device added in v0.8.0

func (e *ErrorEntry) Device() fs.DeviceInfo

func (*ErrorEntry) ErrorInfo added in v0.8.0

func (e *ErrorEntry) ErrorInfo() error

ErrorInfo implements fs.ErrorErntry.

func (*ErrorEntry) IsDir added in v0.8.0

func (e *ErrorEntry) IsDir() bool

func (*ErrorEntry) LocalFilesystemPath added in v0.8.0

func (e *ErrorEntry) LocalFilesystemPath() string

func (*ErrorEntry) ModTime added in v0.8.0

func (e *ErrorEntry) ModTime() time.Time

func (*ErrorEntry) Mode added in v0.8.0

func (e *ErrorEntry) Mode() os.FileMode

func (*ErrorEntry) Name added in v0.8.0

func (e *ErrorEntry) Name() string

func (*ErrorEntry) Owner added in v0.8.0

func (e *ErrorEntry) Owner() fs.OwnerInfo

func (*ErrorEntry) Size added in v0.8.0

func (e *ErrorEntry) Size() int64

func (*ErrorEntry) Sys added in v0.8.0

func (e *ErrorEntry) Sys() interface{}

type File

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

File is an in-memory fs.File capable of simulating failures.

func (*File) Device added in v0.8.0

func (e *File) Device() fs.DeviceInfo

func (*File) IsDir

func (e *File) IsDir() bool

func (*File) LocalFilesystemPath added in v0.8.0

func (e *File) LocalFilesystemPath() string

func (*File) ModTime

func (e *File) ModTime() time.Time

func (*File) Mode

func (e *File) Mode() os.FileMode

func (*File) Name

func (e *File) Name() string

func (*File) Open

func (imf *File) Open(ctx context.Context) (fs.Reader, error)

Open opens the file for reading, optionally simulating error.

func (*File) Owner

func (e *File) Owner() fs.OwnerInfo

func (*File) SetContents

func (imf *File) SetContents(b []byte)

SetContents changes the contents of a given file.

func (*File) Size

func (e *File) Size() int64

func (*File) Sys

func (e *File) Sys() interface{}

type ReaderSeekerCloser

type ReaderSeekerCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

ReaderSeekerCloser implements io.Reader, io.Seeker and io.Closer.

Jump to

Keyboard shortcuts

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