Documentation ¶
Overview ¶
Package ctest provides basic types and functions for controller testing.
Index ¶
- func AssertNoResource[R rtestutils.ResourceWithRD](suiter Suiter, id string, opts ...rtestutils.Option)
- func AssertResource[R rtestutils.ResourceWithRD](suiter Suiter, requiredIDs resource.ID, check func(R, *assert.Assertions), ...)
- func AssertResources[R rtestutils.ResourceWithRD](suiter Suiter, requiredIDs []resource.ID, check func(R, *assert.Assertions), ...)
- func Get[T resource.Resource](suite Suite, ptr resource.Pointer, options ...state.GetOption) (T, error)
- func GetUsingResource[T resource.Resource](suite Suite, res T, options ...state.GetOption) (T, error)
- func UpdateWithConflicts[T resource.Resource](suite Suite, res T, updateFn func(T) error, options ...state.UpdateOption) T
- func WrapRetry(f func(*assert.Assertions, *require.Assertions)) func() error
- type DefaultSuite
- func (suite *DefaultSuite) AssertWithin(d time.Duration, rate time.Duration, fn func() error)
- func (suite *DefaultSuite) Create(res resource.Resource, opts ...state.CreateOption)
- func (suite *DefaultSuite) Ctx() context.Context
- func (suite *DefaultSuite) Runtime() *runtime.Runtime
- func (suite *DefaultSuite) SetupTest()
- func (suite *DefaultSuite) State() state.State
- func (suite *DefaultSuite) TearDownTest()
- type Suite
- type Suiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNoResource ¶
func AssertNoResource[R rtestutils.ResourceWithRD]( suiter Suiter, id string, opts ...rtestutils.Option, )
AssertNoResource asserts that a resource no longer exists.
func AssertResource ¶
func AssertResource[R rtestutils.ResourceWithRD]( suiter Suiter, requiredIDs resource.ID, check func(R, *assert.Assertions), opts ...rtestutils.Option, )
AssertResource asserts on a single resource.
func AssertResources ¶
func AssertResources[R rtestutils.ResourceWithRD]( suiter Suiter, requiredIDs []resource.ID, check func(R, *assert.Assertions), opts ...rtestutils.Option, )
AssertResources asserts on a resource list.
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) Timeout time.Duration // contains filtered or unexported fields }
DefaultSuite is a base suite for controller testing.
func (*DefaultSuite) AssertWithin ¶
AssertWithin asserts that fn returns within the given duration without an error.
func (*DefaultSuite) Create ¶
func (suite *DefaultSuite) Create(res resource.Resource, opts ...state.CreateOption)
Create creates a new resource in the state of the suite.
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.