testing

package
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalledDetail

type CalledDetail struct {
	// Name of the function called.
	Name string
	// Arguments of the function called.
	Arguments []interface{}
}

CalledDetail is the struct contains called function name and arguments.

type FakeOS

type FakeOS struct {
	sync.Mutex
	MkdirAllFn  func(string, os.FileMode) error
	RemoveAllFn func(string) error
	OpenFifoFn  func(context.Context, string, int, os.FileMode) (io.ReadWriteCloser, error)
	StatFn      func(string) (os.FileInfo, error)
	CopyFileFn  func(string, string, os.FileMode) error
	WriteFileFn func(string, []byte, os.FileMode) error
	MountFn     func(source string, target string, fstype string, flags uintptr, data string) error
	UnmountFn   func(target string, flags int) error
	// contains filtered or unexported fields
}

FakeOS mocks out certain OS calls to avoid perturbing the filesystem If a member of the form `*Fn` is set, that function will be called in place of the real call.

func NewFakeOS

func NewFakeOS() *FakeOS

NewFakeOS creates a FakeOS.

func (*FakeOS) ClearErrors

func (f *FakeOS) ClearErrors()

ClearErrors clear errors for call

func (*FakeOS) CopyFile

func (f *FakeOS) CopyFile(src, dest string, perm os.FileMode) error

CopyFile is a fake call that invokes CopyFileFn or just return nil.

func (*FakeOS) GetCalls

func (f *FakeOS) GetCalls() []CalledDetail

GetCalls get detail of calls.

func (*FakeOS) InjectError

func (f *FakeOS) InjectError(fn string, err error)

InjectError inject error for call

func (*FakeOS) InjectErrors

func (f *FakeOS) InjectErrors(errs map[string]error)

InjectErrors inject errors for calls

func (*FakeOS) MkdirAll

func (f *FakeOS) MkdirAll(path string, perm os.FileMode) error

MkdirAll is a fake call that invokes MkdirAllFn or just returns nil.

func (*FakeOS) Mount

func (f *FakeOS) Mount(source string, target string, fstype string, flags uintptr, data string) error

Mount is a fake call that invokes MountFn or just return nil.

func (*FakeOS) OpenFifo

func (f *FakeOS) OpenFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (io.ReadWriteCloser, error)

OpenFifo is a fake call that invokes OpenFifoFn or just returns nil.

func (*FakeOS) RemoveAll

func (f *FakeOS) RemoveAll(path string) error

RemoveAll is a fake call that invokes RemoveAllFn or just returns nil.

func (*FakeOS) Stat

func (f *FakeOS) Stat(name string) (os.FileInfo, error)

Stat is a fake call that invokes StatFn or just return nil.

func (*FakeOS) Unmount

func (f *FakeOS) Unmount(target string, flags int) error

Unmount is a fake call that invokes UnmountFn or just return nil.

func (*FakeOS) WriteFile

func (f *FakeOS) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile is a fake call that invokes WriteFileFn or just return nil.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL