Documentation ¶
Overview ¶
Package ctest provides basic types and functions for controller testing.
Index ¶
- 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) 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
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 ¶
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.