utils

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckError

func CheckError(id string, t *testing.T, expected error, actual error)

func CheckErrorGlob

func CheckErrorGlob(id string, t *testing.T, pattern error, actual error)

func CheckOutput

func CheckOutput(id string, t *testing.T, expected interface{}, actual interface{}, opts ...cmp.Option)

func ExpectErr

func ExpectErr(id string, t *testing.T, shouldExpectErr bool, err error)

func Safe

func Safe[T any](t *T) T

This function ingests the pointer of any type and returns the zero value if the pointer is nil. Otherwise, returns the dereferenced value.

Types

type Binary

type Binary string
const (
	Lsblk     Binary = "lsblk"
	MkfsExt4  Binary = "mkfs.ext4"
	E2Label   Binary = "e2label"
	MkfsXfs   Binary = "mkfs.xfs"
	XfsAdmin  Binary = "xfs_admin"
	Mount     Binary = "mount"
	Umount    Binary = "umount"
	BlockDev  Binary = "blockdev"
	Tune2fs   Binary = "tune2fs"
	XfsInfo   Binary = "xfs_info"
	Resize2fs Binary = "resize2fs"
	XfsGrowfs Binary = "xfs_growfs"
)

type ExecRunner

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

func NewExecRunner

func NewExecRunner(binary Binary) *ExecRunner

func (*ExecRunner) Command

func (er *ExecRunner) Command(arg ...string) (string, error)

type ExecRunnerFactory

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

func NewExecRunnerFactory

func NewExecRunnerFactory() *ExecRunnerFactory

func (*ExecRunnerFactory) Select

func (rc *ExecRunnerFactory) Select(binary Binary) Runner

Caching behaviour is implemented for ExecRunnerFactory as we do not need to validate an ExecRunner more than once

type MockIncrementError

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

func NewMockIncrementError

func NewMockIncrementError(id string, errorType MockIncrementErrorType, trigger uint32) *MockIncrementError

func (*MockIncrementError) Error

func (mie *MockIncrementError) Error() string

func (*MockIncrementError) Trigger

func (mie *MockIncrementError) Trigger() error

type MockIncrementErrorType

type MockIncrementErrorType string
const (
	ErrorUntilTrigger   MockIncrementErrorType = "ErrorUntilTrigger"
	SuccessUntilTrigger MockIncrementErrorType = "SuccessUntilTrigger"
)

type MockRunner

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

func NewMockRunner

func NewMockRunner(expectedArgs []string, output string, err error) *MockRunner

func (*MockRunner) Command

func (mr *MockRunner) Command(arg ...string) (string, error)

type MockRunnerFactory

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

func NewMockRunnerFactory

func NewMockRunnerFactory(expectedBinary Binary, expectedArgs []string, output string, err error) *MockRunnerFactory

func (*MockRunnerFactory) Select

func (mrf *MockRunnerFactory) Select(binary Binary) Runner

type NotImeplementedError

type NotImeplementedError struct {
	Id string
}

func NewNotImeplementedError

func NewNotImeplementedError(id string) *NotImeplementedError

func (*NotImeplementedError) Error

func (e *NotImeplementedError) Error() string

type Runner

type Runner interface {
	Command(arg ...string) (string, error)
}

type RunnerFactory

type RunnerFactory interface {
	Select(binary Binary) Runner
}

Jump to

Keyboard shortcuts

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