mockfs

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 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.ds

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) 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) 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) 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) 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) 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) Summary

func (imd *Directory) Summary() *fs.DirectorySummary

Summary returns summary of a directory.

func (Directory) Sys

func (e Directory) 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) IsDir

func (e File) IsDir() bool

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