ctest

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package ctest provides basic types and functions for controller testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T resource.Resource](suite Suite, ptr resource.Pointer, options ...state.GetOption) (T, error)

Get is a type safe wrapper around state.Get which uses the provided suite.

func GetUsingResource

func GetUsingResource[T resource.Resource](suite Suite, res T, options ...state.GetOption) (T, error)

GetUsingResource is a type safe wrapper around state.StateGetResource which uses the provided suite.

func UpdateWithConflicts

func UpdateWithConflicts[T resource.Resource](suite Suite, res T, updateFn func(T) error, options ...state.UpdateOption) T

UpdateWithConflicts is a type safe wrapper around state.UpdateWithConflicts which uses the provided suite.

func WrapRetry

func WrapRetry(f func(*assert.Assertions, *require.Assertions)) func() error

WrapRetry wraps the function with assertions and requires to return retry-compatible errors.

Types

type DefaultSuite

type DefaultSuite struct {
	suite.Suite

	AfterSetup    func(suite *DefaultSuite)
	AfterTearDown func(suite *DefaultSuite)
	// contains filtered or unexported fields
}

DefaultSuite is a base suite for controller testing.

func (*DefaultSuite) AssertWithin

func (suite *DefaultSuite) AssertWithin(d time.Duration, rate time.Duration, fn func() error)

AssertWithin asserts that fn returns within the given duration without an error.

func (*DefaultSuite) Ctx

func (suite *DefaultSuite) Ctx() context.Context

Ctx returns the context of the suite.

func (*DefaultSuite) Runtime

func (suite *DefaultSuite) Runtime() *runtime.Runtime

Runtime returns the runtime of the suite.

func (*DefaultSuite) SetupTest

func (suite *DefaultSuite) SetupTest()

SetupTest is a function for setting up a test.

func (*DefaultSuite) State

func (suite *DefaultSuite) State() state.State

State returns the state of the suite.

func (*DefaultSuite) TearDownTest

func (suite *DefaultSuite) TearDownTest()

TearDownTest is a function for tearing down a test.

type Suite

type Suite interface {
	T() *testing.T
	Require() *require.Assertions
	State() state.State
	Ctx() context.Context
}

Suite is a type which dectibes the suite type.

Jump to

Keyboard shortcuts

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