testutils

package module
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Environ = processEnvironment(&realEnvironment{})

Functions

func CaptureStdout

func CaptureStdout(t *testing.T, fn func()) string

func DoMapsMatch

func DoMapsMatch(t *testing.T, expectedMap map[string]interface{}, testMap map[string]interface{})

func ExpectBool

func ExpectBool(t *testing.T, expectedBool bool, testBool bool)

func ExpectError

func ExpectError(t *testing.T, expectedError error, testError error)

func ExpectErrorContainingText

func ExpectErrorContainingText(t *testing.T, expectedSubtext string, testError error)

func ExpectFileExists added in v1.0.3

func ExpectFileExists(io FileIo, t *testing.T, filePath string)

func ExpectFileJson added in v1.0.3

func ExpectFileJson(io FileIo, t *testing.T, filePath string, data map[string]interface{})

func ExpectFileJsonPart added in v1.0.3

func ExpectFileJsonPart(io FileIo, t *testing.T, filePath string, subsetData map[string]interface{})

func ExpectFileNotExists added in v1.0.7

func ExpectFileNotExists(io FileIo, t *testing.T, filePath string)

func ExpectPanic

func ExpectPanic(t *testing.T, fn func())

func ExpectPanicError

func ExpectPanicError(t *testing.T, expectedError error, fn func())

func ExpectString

func ExpectString(t *testing.T, expectedStr string, testStr string)

func ExpectValue

func ExpectValue(t *testing.T, expectedVal interface{}, testVal interface{})

func NewTestEnvironment added in v1.0.11

func NewTestEnvironment() *testEnvironment

func NiceJs added in v1.0.3

func NiceJs(testJson string) string

func NiceYaml added in v1.0.3

func NiceYaml(testYaml string) string

Types

type FileIo added in v1.0.3

type FileIo interface {
	ReadFile(filePath string) ([]byte, error)
	WriteFile(filePath string, data []byte, perm fs.FileMode) error
	Stat(name string) (os.FileInfo, error)
	MkdirAll(name string, perm fs.FileMode) error
	RemoveAll(name string) error
	IsDirectory(name string) (bool, error)
	CopyFile(src, dest string) (int64, error)
	ReadDir(src string) ([]fs.DirEntry, error)
	FileExists(name string) (bool, error)
	Walk(root string, fn filepath.WalkFunc) error
	Chtimes(name string, atime, mtime time.Time) error
}

func NewFileIo added in v1.0.3

func NewFileIo() FileIo

type TestFile added in v1.0.3

type TestFile struct {
	// contains filtered or unexported fields
}

type TestFileHook added in v1.0.5

type TestFileHook func(args ...string) error

type TestFileInfo added in v1.0.3

type TestFileInfo struct {
	// contains filtered or unexported fields
}

func (*TestFileInfo) IsDir added in v1.0.3

func (tfi *TestFileInfo) IsDir() bool

func (*TestFileInfo) ModTime added in v1.0.3

func (tfi *TestFileInfo) ModTime() time.Time

func (*TestFileInfo) Mode added in v1.0.3

func (tfi *TestFileInfo) Mode() os.FileMode

func (*TestFileInfo) Name added in v1.0.3

func (tfi *TestFileInfo) Name() string

func (*TestFileInfo) Size added in v1.0.3

func (tfi *TestFileInfo) Size() int64

func (*TestFileInfo) Sys added in v1.0.3

func (tfi *TestFileInfo) Sys() interface{}

type TestFileIo added in v1.0.3

type TestFileIo struct {
	ForceError map[string]error
	Hooks      map[string]TestFileHook
	// contains filtered or unexported fields
}

func NewTestFileIo added in v1.0.3

func NewTestFileIo() *TestFileIo

func (*TestFileIo) Chtimes added in v1.0.10

func (tfi *TestFileIo) Chtimes(name string, atime, mtime time.Time) error

func (*TestFileIo) CopyFile added in v1.0.3

func (tfi *TestFileIo) CopyFile(src, dest string) (int64, error)

func (*TestFileIo) Dump added in v1.0.3

func (tfi *TestFileIo) Dump()

func (*TestFileIo) FileExists added in v1.0.3

func (tfi *TestFileIo) FileExists(name string) (bool, error)

func (*TestFileIo) IsDirectory added in v1.0.3

func (tfi *TestFileIo) IsDirectory(name string) (bool, error)

func (*TestFileIo) IsEmptyDir added in v1.0.3

func (tfi *TestFileIo) IsEmptyDir(name string) bool

func (*TestFileIo) MkdirAll added in v1.0.3

func (tfi *TestFileIo) MkdirAll(name string, perm fs.FileMode) error

func (*TestFileIo) ReadDir added in v1.0.3

func (tfi *TestFileIo) ReadDir(src string) (files []fs.DirEntry, err error)

func (*TestFileIo) ReadFile added in v1.0.3

func (tfi *TestFileIo) ReadFile(filePath string) ([]byte, error)

func (*TestFileIo) RemoveAll added in v1.0.3

func (tfi *TestFileIo) RemoveAll(name string) error

func (*TestFileIo) Stat added in v1.0.3

func (tfi *TestFileIo) Stat(name string) (os.FileInfo, error)

func (*TestFileIo) Walk added in v1.0.8

func (tfi *TestFileIo) Walk(root string, fn filepath.WalkFunc) (err error)

func (*TestFileIo) WriteFile added in v1.0.3

func (tfi *TestFileIo) WriteFile(filePath string, data []byte, perm fs.FileMode) error

Jump to

Keyboard shortcuts

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