testhelpers

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateInitialState

func CreateInitialState(config InitialStateConfig, opts ...InitialStateOpt) *core.State

func CreateVmInfo

func CreateVmInfo(config InitialVmInfoConfig, opts ...VmInfoOpt) api.VmInfo

Types

type Assert

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

func NewAssert

func NewAssert(t *testing.T) Assert

NewAssert creates a new Assert object wrapping the provided *testing.T

func (Assert) Call

func (a Assert) Call(f any, args ...any) PreparedFunctionCall

Call sets up a prepared function call, which will not be executed until one of its methods is actually called, which will perform all the relevant checks.

Variadic functions are not supported.

func (Assert) Do

func (a Assert) Do(f any, args ...any)

Do calls the function with the provided arguments, checking that no unexpected warnings were generated

This is only valid for functions that return nothing.

func (Assert) NoError

func (a Assert) NoError(f any, args ...any)

NoError calls the function with the provided arguments, checking that the error it returns is nil, and that no unexpected warnings were generated.

func (Assert) StoredWarnings

func (a Assert) StoredWarnings() *[]string

StoredWarnings returns a reference to the warnings that will be checked, intended to be used with the InitialStateOpt constructor WithStoredWarnings

func (Assert) WithWarnings

func (a Assert) WithWarnings(warnings ...string) Assert

WithWarnings returns an Assert that expects the given warnings to be emitted on each operation

type Elapsed

type Elapsed struct {
	time.Duration
	// contains filtered or unexported fields
}

func (Elapsed) AssertEquals

func (e Elapsed) AssertEquals(expected time.Duration)

type FakeClock

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

FakeClock is a small facility that makes it easy to operate on duration since start with relative times, rather than absolute times.

func NewFakeClock

func NewFakeClock(t *testing.T) *FakeClock

NewFakeClock creates a new fake clock, with the initial time set to an unspecified, round number.

func (*FakeClock) Elapsed

func (c *FakeClock) Elapsed() Elapsed

Elapsed returns the total time added (via Inc) since the clock was started

func (*FakeClock) Inc

func (c *FakeClock) Inc(duration time.Duration) Elapsed

Inc adds duration to the current time of the clock

func (*FakeClock) Now

func (c *FakeClock) Now() time.Time

Now returns the current time of the clock

type InitialStateConfig

type InitialStateConfig struct {
	VM InitialVmInfoConfig

	Core core.Config
}

type InitialStateOpt

type InitialStateOpt interface {
	// contains filtered or unexported methods
}

func WithConfigSetting

func WithConfigSetting(f func(*core.Config)) InitialStateOpt

func WithStoredWarnings

func WithStoredWarnings(warnings *[]string) InitialStateOpt

func WithTestingLogfWarnings

func WithTestingLogfWarnings(t *testing.T) InitialStateOpt

type InitialVmInfoConfig

type InitialVmInfoConfig struct {
	ComputeUnit    api.Resources
	MemorySlotSize api.Bytes

	MinCU uint16
	MaxCU uint16
}

type PreparedFunctionCall

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

PreparedFunctionCall is a function call that has been set up by (Assert).Call() but not executed

func (PreparedFunctionCall) Equals

func (f PreparedFunctionCall) Equals(expected ...any)

Equals calls the prepared function, checking that all the return values are equal to what's expected, and that no unexpected warnings were generated.

type VmInfoOpt

type VmInfoOpt interface {
	InitialStateOpt
	// contains filtered or unexported methods
}

func WithCurrentCU

func WithCurrentCU(cu uint16) VmInfoOpt

func WithMinMaxCU

func WithMinMaxCU(minCU, maxCU uint16) VmInfoOpt

Jump to

Keyboard shortcuts

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