Documentation
¶
Overview ¶
Package testutil provides utilities for reading testdata from children directories.
Index ¶
- func ChangeToBazelDir(curDir string)
- func CheckErrorCases(err error, expErrSubstr string) error
- type FakeFileReaderWriter
- func (f *FakeFileReaderWriter) AddReadFile(fp *FilePair)
- func (f *FakeFileReaderWriter) ReadFile(_ context.Context, path string) ([]byte, error)
- func (f *FakeFileReaderWriter) ReadFileObj(ctx context.Context, file bundle.File) ([]byte, error)
- func (f *FakeFileReaderWriter) WriteFile(_ context.Context, path string, contents []byte, permissions os.FileMode) error
- type FilePair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeToBazelDir ¶ added in v0.9.1
func ChangeToBazelDir(curDir string)
ChangeToBazelDir changes the CWD to a bazel directory if necessary. pathToDir specifies the path from the root bazel-directory to the relevant directory. If changing the directory fails, the method panics.
func CheckErrorCases ¶ added in v0.8.0
CheckErrorCases checks error cases for tests
Types ¶
type FakeFileReaderWriter ¶ added in v0.11.0
type FakeFileReaderWriter struct {
// ReadFiles contains mapping of path-to-file for files to-read. If
// AlwaysRead is empty and the a path is supplied to read that is not in the
// ReadFiles, an error will be returned.
ReadFiles map[string]string
// If AlwaysRead is present, always return the always read object.
AlwaysRead string
// ReadErr forces an error to occur during read.
ReadErr error
// WriteFiles records what files have been written
WriteFiles map[string]string
// WriteErr forces an error to occur during write.
WriteErr error
}
FakeFileReaderWriter is a fake implementation of FileReaderWriter for unit tests.
func NewEmptyReaderWriter ¶
func NewEmptyReaderWriter() *FakeFileReaderWriter
NewEmptyReaderWriter creates an empty FakeFileReaderWriter. It will return an error on all paths returned from reads and succeed on all writes.
func (*FakeFileReaderWriter) AddReadFile ¶ added in v0.11.0
func (f *FakeFileReaderWriter) AddReadFile(fp *FilePair)
AddReadFile adds a file to the ReadFiles map.
func (*FakeFileReaderWriter) ReadFileObj ¶ added in v0.11.0
ReadFileObj reads a File object by deferring to the internal map.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package componentsuite provides a test-suite helper for running component tests.
|
Package componentsuite provides a test-suite helper for running component tests. |