filetesting

package
v0.0.0-...-692d58e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2016 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStubReader

func NewStubReader(stub *testing.Stub, content string) io.Reader

func NewStubWriter

func NewStubWriter(stub *testing.Stub) (io.Writer, *bytes.Buffer)

Types

type Dir

type Dir struct {
	Path string
	Perm os.FileMode
}

Dir is an Entry that allows directories to be created and verified. The Path field should use "/" as the path separator.

func (Dir) Check

func (d Dir) Check(c *gc.C, basePath string) Entry

func (Dir) Create

func (d Dir) Create(c *gc.C, basePath string) Entry

func (Dir) GetPath

func (d Dir) GetPath() string

type Entries

type Entries []Entry

Entries supplies convenience methods on Entry slices.

func (Entries) AsRemoveds

func (e Entries) AsRemoveds() Entries

AsRemoveds returns a slice of Removed entries whose paths correspond to those in e.

func (Entries) Check

func (e Entries) Check(c *gc.C, basePath string) Entries

Check checks every entry relative to basePath and returns a copy of itself.

func (Entries) Create

func (e Entries) Create(c *gc.C, basePath string) Entries

Create creates every entry relative to basePath and returns a copy of itself.

func (Entries) Paths

func (e Entries) Paths() []string

Paths returns the slash-separated path of every entry.

type Entry

type Entry interface {

	// GetPath returns the slash-separated relative path that this
	// entry represents.
	GetPath() string

	// Create causes the entry to be created, relative to basePath. It returns
	// a copy of the receiver.
	Create(c *gc.C, basePath string) Entry

	// Check checks that the entry exists, relative to basePath, and matches
	// the entry that would be created by Create. It returns a copy of the
	// receiver.
	Check(c *gc.C, basePath string) Entry
}

Entry represents a filesystem entity that can be created; and whose correctness can be verified.

type File

type File struct {
	Path string
	Data string
	Perm os.FileMode
}

File is an Entry that allows plain files to be created and verified. The Path field should use "/" as the path separator.

func (File) Check

func (f File) Check(c *gc.C, basePath string) Entry

func (File) Create

func (f File) Create(c *gc.C, basePath string) Entry

func (File) GetPath

func (f File) GetPath() string

type FileInfo

type FileInfo struct {
	Name    string
	Size    int64
	Mode    os.FileMode
	ModTime time.Time
}

type Removed

type Removed struct {
	Path string
}

Removed is an Entry that indicates the absence of any entry. The Path field should use "/" as the path separator.

func (Removed) Check

func (r Removed) Check(c *gc.C, basePath string) Entry

func (Removed) Create

func (r Removed) Create(c *gc.C, basePath string) Entry

func (Removed) GetPath

func (r Removed) GetPath() string

type StubCloser

type StubCloser struct {
	Stub *testing.Stub
}

func (*StubCloser) Close

func (s *StubCloser) Close() error

type StubFile

type StubFile struct {
	io.Reader
	io.Writer
	io.Seeker
	io.Closer

	Stub *testing.Stub
	Info StubFileInfo
}

func NewStubFile

func NewStubFile(stub *testing.Stub, raw io.ReadWriter) *StubFile

func (*StubFile) Name

func (s *StubFile) Name() string

func (*StubFile) Stat

func (s *StubFile) Stat() (os.FileInfo, error)

func (*StubFile) Sync

func (s *StubFile) Sync() error

func (*StubFile) Truncate

func (s *StubFile) Truncate(size int64) error

type StubFileInfo

type StubFileInfo struct {
	Stub *testing.Stub

	Info      FileInfo
	ReturnSys interface{}
}

func NewStubFileInfo

func NewStubFileInfo(stub *testing.Stub, name, content string) *StubFileInfo

func (StubFileInfo) IsDir

func (s StubFileInfo) IsDir() bool

func (StubFileInfo) ModTime

func (s StubFileInfo) ModTime() time.Time

func (StubFileInfo) Mode

func (s StubFileInfo) Mode() os.FileMode

func (StubFileInfo) Name

func (s StubFileInfo) Name() string

func (StubFileInfo) Size

func (s StubFileInfo) Size() int64

func (StubFileInfo) Sys

func (s StubFileInfo) Sys() interface{}

type StubHash

type StubHash struct {
	io.Writer

	Stub            *testing.Stub
	ReturnSum       []byte
	ReturnSize      int
	ReturnBlockSize int
}

func NewStubHash

func NewStubHash(stub *testing.Stub, raw io.Writer) *StubHash

func (*StubHash) BlockSize

func (s *StubHash) BlockSize() int

func (*StubHash) Reset

func (s *StubHash) Reset()

func (*StubHash) Size

func (s *StubHash) Size() int

func (*StubHash) Sum

func (s *StubHash) Sum(b []byte) []byte

type StubReader

type StubReader struct {
	Stub *testing.Stub

	ReturnRead io.Reader
}

func (*StubReader) Read

func (s *StubReader) Read(data []byte) (int, error)

type StubSeeker

type StubSeeker struct {
	Stub *testing.Stub

	ReturnSeek int64
}

func (*StubSeeker) Seek

func (s *StubSeeker) Seek(offset int64, whence int) (int64, error)

type StubWriter

type StubWriter struct {
	Stub *testing.Stub

	ReturnWrite io.Writer
}

func (*StubWriter) Write

func (s *StubWriter) Write(data []byte) (int, error)
type Symlink struct {
	Path string
	Link string
}

Symlink is an Entry that allows symlinks to be created and verified. The Path field should use "/" as the path separator.

func (Symlink) Check

func (s Symlink) Check(c *gc.C, basePath string) Entry

func (Symlink) Create

func (s Symlink) Create(c *gc.C, basePath string) Entry

func (Symlink) GetPath

func (s Symlink) GetPath() string

Jump to

Keyboard shortcuts

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