filesystem

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package filesystem is a mock filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockFile

type MockFile struct {
	mock.Mock
	// contains filtered or unexported fields
}

MockFile is the simple implementation of vfs.ReadSeekCloser.

var NilFile *MockFile

NilFile is a nil mockfile for easy reference.

func NewMockFile

func NewMockFile(name string, data []byte) *MockFile

NewMockFile creates a new mock file for use with the mock file system.

func (*MockFile) Close

func (m *MockFile) Close() error

Close does nothing.

func (*MockFile) IsDir

func (m *MockFile) IsDir() bool

IsDir is an abbreviation for Mode().IsDir().

func (*MockFile) ModTime

func (m *MockFile) ModTime() time.Time

ModTime returns the modification time.

func (*MockFile) Mode

func (m *MockFile) Mode() os.FileMode

Mode returns the file mode bits.

func (*MockFile) Name

func (m *MockFile) Name() string

Name returns the base name of the file.

func (*MockFile) Read

func (m *MockFile) Read(dst []byte) (int, error)

Read reads from the buffer.

func (*MockFile) Seek

func (m *MockFile) Seek(offset int64, whence int) (int64, error)

Seek sets the read/write header.

func (*MockFile) Size

func (m *MockFile) Size() int64

Size returns the length in bytes for regular files; system-dependent for others.

func (*MockFile) Sys

func (m *MockFile) Sys() interface{}

Sys returns the underlying data source (can return nil).

type MockFileSystem added in v3.0.2

type MockFileSystem struct {
	mock.Mock
}

MockFileSystem is a mock implementation of the Opener interface, for testing purposes.

func NewMockFileSystem

func NewMockFileSystem(files ...*MockFile) *MockFileSystem

NewMockFileSystem creates a new mock Reader.

func (*MockFileSystem) Lstat added in v3.0.2

func (m *MockFileSystem) Lstat(path string) (os.FileInfo, error)

Lstat does stat stuff.

func (*MockFileSystem) Open added in v3.0.2

func (m *MockFileSystem) Open(filename string) (vfs.ReadSeekCloser, error)

Open returns a pre-set data/error pair.

func (*MockFileSystem) ReadDir added in v3.0.2

func (m *MockFileSystem) ReadDir(path string) ([]os.FileInfo, error)

ReadDir walks the directory.

func (*MockFileSystem) RootType added in v3.0.2

func (m *MockFileSystem) RootType(path string) vfs.RootType

RootType returns the Root Type.

func (*MockFileSystem) Stat added in v3.0.2

func (m *MockFileSystem) Stat(path string) (os.FileInfo, error)

Stat gets file stats.

func (*MockFileSystem) String added in v3.0.2

func (m *MockFileSystem) String() string

Jump to

Keyboard shortcuts

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