utiltest

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureStderr

func CaptureStderr(fn func()) (string, error)

func Run

func Run(t *testing.T, s suite.TestingSuite)

Run takes a testing suite and runs all of the tests attached to it.

Types

type EnvVarHelper

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

func (*EnvVarHelper) Setup

func (h *EnvVarHelper) Setup(vars ...string)

func (*EnvVarHelper) Teardown

func (h *EnvVarHelper) Teardown()

type MockFile

type MockFile struct {
	mock.Mock
}

func NewMockFile

func NewMockFile() *MockFile

func (*MockFile) Close

func (m *MockFile) Close() error

func (*MockFile) Name

func (m *MockFile) Name() string

func (*MockFile) Read

func (m *MockFile) Read(p []byte) (n int, err error)

func (*MockFile) ReadAt

func (m *MockFile) ReadAt(p []byte, off int64) (n int, err error)

func (*MockFile) Readdir

func (m *MockFile) Readdir(count int) ([]os.FileInfo, error)

func (*MockFile) Readdirnames

func (m *MockFile) Readdirnames(n int) ([]string, error)

func (*MockFile) Seek

func (m *MockFile) Seek(offset int64, whence int) (int64, error)

func (*MockFile) Stat

func (m *MockFile) Stat() (os.FileInfo, error)

func (*MockFile) Sync

func (m *MockFile) Sync() error

func (*MockFile) Truncate

func (m *MockFile) Truncate(size int64) error

func (*MockFile) Write

func (m *MockFile) Write(p []byte) (n int, err error)

func (*MockFile) WriteAt

func (m *MockFile) WriteAt(p []byte, off int64) (n int, err error)

func (*MockFile) WriteString

func (m *MockFile) WriteString(s string) (int, error)

type MockFileInfo

type MockFileInfo struct {
	mock.Mock
}

func NewMockFileInfo

func NewMockFileInfo() *MockFileInfo

func (*MockFileInfo) IsDir

func (m *MockFileInfo) IsDir() bool

func (*MockFileInfo) ModTime

func (m *MockFileInfo) ModTime() time.Time

func (*MockFileInfo) Mode

func (m *MockFileInfo) Mode() fs.FileMode

func (*MockFileInfo) Name

func (m *MockFileInfo) Name() string

func (*MockFileInfo) Size

func (m *MockFileInfo) Size() int64

func (*MockFileInfo) Sys

func (m *MockFileInfo) Sys() any

type MockFs

type MockFs struct {
	mock.Mock
}

func NewMockFs

func NewMockFs() *MockFs

func (*MockFs) Chmod

func (m *MockFs) Chmod(name string, mode os.FileMode) error

func (*MockFs) Chown

func (m *MockFs) Chown(name string, uid, gid int) error

func (*MockFs) Chtimes

func (m *MockFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*MockFs) Create

func (m *MockFs) Create(name string) (afero.File, error)

func (*MockFs) Mkdir

func (m *MockFs) Mkdir(name string, perm os.FileMode) error

func (*MockFs) MkdirAll

func (m *MockFs) MkdirAll(path string, perm os.FileMode) error

func (*MockFs) Name

func (m *MockFs) Name() string

func (*MockFs) Open

func (m *MockFs) Open(name string) (afero.File, error)

func (*MockFs) OpenFile

func (m *MockFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

func (*MockFs) Remove

func (m *MockFs) Remove(name string) error

func (*MockFs) RemoveAll

func (m *MockFs) RemoveAll(path string) error

func (*MockFs) Rename

func (m *MockFs) Rename(oldname, newname string) error

func (*MockFs) Stat

func (m *MockFs) Stat(name string) (os.FileInfo, error)

type MockReader

type MockReader struct {
	mock.Mock
}

func NewMockReader

func NewMockReader() *MockReader

func (*MockReader) Read

func (m *MockReader) Read(p []byte) (n int, err error)

type MockTarWriter

type MockTarWriter struct {
	mock.Mock
}

func NewMockTarWriter

func NewMockTarWriter() *MockTarWriter

func (*MockTarWriter) Close

func (m *MockTarWriter) Close() error

func (*MockTarWriter) Write

func (m *MockTarWriter) Write(p []byte) (int, error)

func (*MockTarWriter) WriteHeader

func (m *MockTarWriter) WriteHeader(hdr *tar.Header) error

type MockWriter

type MockWriter struct {
	mock.Mock
}

func NewMockWriter

func NewMockWriter() *MockWriter

func (*MockWriter) Write

func (m *MockWriter) Write(p []byte) (n int, err error)

type Suite

type Suite struct {
	*require.Assertions
	// contains filtered or unexported fields
}

Suite is a basic testing suite with methods for storing and retrieving the current *testing.T context.

func (*Suite) Assert

func (s *Suite) Assert() *assert.Assertions

Assert returns an assert context for suite. Normally, you can call `suite.NoError(expected, actual)`, but for situations where the embedded methods are overridden (for example, you might want to override assert.Assertions with require.Assertions), this method is provided so you can call `suite.Assert().NoError()`.

func (*Suite) Require

func (s *Suite) Require() *require.Assertions

Require returns a require context for suite.

func (*Suite) Run

func (s *Suite) Run(name string, subtest func()) bool

Run provides suite functionality around golang subtests. It should be called in place of t.Run(name, func(t *testing.T)) in test suite code. The passed-in func will be executed as a subtest with a fresh instance of t. Provides compatibility with go test pkg -run TestSuite/TestName/SubTestName.

func (*Suite) SetS

func (s *Suite) SetS(newS suite.TestingSuite)

SetS needs to set the current test suite as parent to get access to the parent methods

func (*Suite) SetT

func (s *Suite) SetT(t *testing.T)

SetT sets the current *testing.T context.

func (*Suite) T

func (s *Suite) T() *testing.T

T retrieves the current *testing.T context.

type SuiteInformation

type SuiteInformation struct {
	suite.SuiteInformation
}

SuiteInformation stats stores stats for the whole suite execution.

Jump to

Keyboard shortcuts

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