filetesting
v1.2.1
Documentation
pkg.go.dev ↗Functions
NewStubReader
func NewStubReader(stub *testing.Stub, content string) io.Reader
NewStubWriter
func NewStubWriter(stub *testing.Stub) (io.Writer, *bytes.Buffer)
Types
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.
Dir.Check
func (d Dir) Check(c *gc.C, basePath string) Entry
Dir.Create
func (d Dir) Create(c *gc.C, basePath string) Entry
Dir.GetPath
func (d Dir) GetPath() string
Entries
type Entries []Entry
Entries supplies convenience methods on Entry slices.
Entries.AsRemoveds
func (e Entries) AsRemoveds() Entries
AsRemoveds returns a slice of Removed entries whose paths correspond to those in e.
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.
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.
Entries.Paths
func (e Entries) Paths() []string
Paths returns the slash-separated path of every entry.
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.
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.
File.Check
func (f File) Check(c *gc.C, basePath string) Entry
File.Create
func (f File) Create(c *gc.C, basePath string) Entry
File.GetPath
func (f File) GetPath() string
FileInfo
type FileInfo struct {
Name string
Size int64
Mode os.FileMode
ModTime time.Time
}
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.
Removed.Check
func (r Removed) Check(c *gc.C, basePath string) Entry
Removed.Create
func (r Removed) Create(c *gc.C, basePath string) Entry
Removed.GetPath
func (r Removed) GetPath() string
StubCloser
type StubCloser struct {
Stub *testing.Stub
}
StubCloser.Close
func (s *StubCloser) Close() error
StubFile
type StubFile struct {
io.Reader
io.Writer
io.Seeker
io.Closer
Stub *testing.Stub
Info StubFileInfo
}
NewStubFile
func NewStubFile(stub *testing.Stub, raw io.ReadWriter) *StubFile
StubFile.Name
func (s *StubFile) Name() string
StubFile.Stat
func (s *StubFile) Stat() (os.FileInfo, error)
StubFile.Sync
func (s *StubFile) Sync() error
StubFile.Truncate
func (s *StubFile) Truncate(size int64) error
StubFileInfo
type StubFileInfo struct {
Stub *testing.Stub
Info FileInfo
ReturnSys interface{}
}
NewStubFileInfo
func NewStubFileInfo(stub *testing.Stub, name, content string) *StubFileInfo
StubFileInfo.IsDir
func (s StubFileInfo) IsDir() bool
StubFileInfo.ModTime
func (s StubFileInfo) ModTime() time.Time
StubFileInfo.Mode
func (s StubFileInfo) Mode() os.FileMode
StubFileInfo.Name
func (s StubFileInfo) Name() string
StubFileInfo.Size
func (s StubFileInfo) Size() int64
StubFileInfo.Sys
func (s StubFileInfo) Sys() interface{}
StubHash
type StubHash struct {
io.Writer
Stub *testing.Stub
ReturnSum []byte
ReturnSize int
ReturnBlockSize int
}
NewStubHash
func NewStubHash(stub *testing.Stub, raw io.Writer) *StubHash
StubHash.BlockSize
func (s *StubHash) BlockSize() int
StubHash.Reset
func (s *StubHash) Reset()
StubHash.Size
func (s *StubHash) Size() int
StubHash.Sum
func (s *StubHash) Sum(b []byte) []byte
StubReader
type StubReader struct {
Stub *testing.Stub
ReturnRead io.Reader
}
StubReader.Read
func (s *StubReader) Read(data []byte) (int, error)
StubSeeker
type StubSeeker struct {
Stub *testing.Stub
ReturnSeek int64
}
StubSeeker.Seek
func (s *StubSeeker) Seek(offset int64, whence int) (int64, error)
StubWriter
type StubWriter struct {
Stub *testing.Stub
ReturnWrite io.Writer
}
StubWriter.Write
func (s *StubWriter) Write(data []byte) (int, error)
Symlink
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.
Symlink.Check
func (s Symlink) Check(c *gc.C, basePath string) Entry
Symlink.Create
func (s Symlink) Create(c *gc.C, basePath string) Entry
Symlink.GetPath
func (s Symlink) GetPath() string