Documentation ¶
Index ¶
- type Case
- type CheckCase
- type CheckInput
- type ConfigCase
- type Handler
- type InCase
- type InInput
- type MockCheckResource
- type MockInResource
- type MockOutResource
- type MockResource
- type OutCase
- type OutInput
- type ResourceTestSuite
- func (s *ResourceTestSuite[cfgType]) SetCheckCases(checkCases map[string]CheckCase[cfgType])
- func (s *ResourceTestSuite[cfgType]) SetConfigCases(configCases map[string]ConfigCase[cfgType])
- func (s *ResourceTestSuite[cfgType]) SetInCases(inCases map[string]InCase[cfgType])
- func (s *ResourceTestSuite[cfgType]) SetOutCases(outCases map[string]OutCase[cfgType])
- func (s *ResourceTestSuite[cfgType]) SetupSuite()
- func (s *ResourceTestSuite[cfgType]) TestCheck()
- func (s *ResourceTestSuite[cfgType]) TestConfig()
- func (s *ResourceTestSuite[cfgType]) TestIn()
- func (s *ResourceTestSuite[cfgType]) TestOut()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Case ¶
type Case struct { ShouldFail bool // defines if the testcase should fail ErrorString string // an optional error message to with Validation func(assert *assert.Assertions, resource any) bool // an optional validation function }
Case defines the input and expected result of a single test
type CheckCase ¶
type CheckCase[cfgType any] struct { Case Input CheckInput[cfgType] Output types.CheckOutput }
CheckCase defines a testcase for the `check` action
type CheckInput ¶
CheckInput is a dummy input for a `check` test
type ConfigCase ¶
ConfigCase defines a testcase for the construction of a new resource
type Handler ¶
type Handler[T any] struct { // contains filtered or unexported fields }
A Handler for your tests.
func NewHandler ¶
NewHandler creates a new testing Handler
func (*Handler[T]) RunConfig ¶
func (h *Handler[T]) RunConfig(c ConfigCase[T]) bool
RunConfig executes a single ConfigCase
type MockCheckResource ¶
type MockCheckResource interface { types.InResource ValidateCheck(assert *assert.Assertions, expectedVersion any) bool }
type MockInResource ¶
type MockInResource interface { types.InResource ValidateIn(assert *assert.Assertions, expectedVersion, expectedParams any) bool }
type MockOutResource ¶
type MockOutResource interface { types.InResource ValidateOut(assert *assert.Assertions, expectedParams any) bool }
type MockResource ¶
type MockResource[cfgType any] interface { Validate(assert *assert.Assertions, expected cfgType) bool }
type ResourceTestSuite ¶
type ResourceTestSuite[cfgType any] struct { suite.Suite // contains filtered or unexported fields }
ResourceTestSuite provides the ability to run multiple tests, simply by providing maps of test cases.
If no case is given for a test type, the subtest will return a SUCCESS status
func NewSuite ¶
func NewSuite[cfgType any](constructor resource.NewResource[cfgType]) *ResourceTestSuite[cfgType]
NewSuite creates a new suite.Suite
func (*ResourceTestSuite[cfgType]) SetCheckCases ¶
func (s *ResourceTestSuite[cfgType]) SetCheckCases(checkCases map[string]CheckCase[cfgType])
SetCheckCases sets the list of CheckCase tests
func (*ResourceTestSuite[cfgType]) SetConfigCases ¶
func (s *ResourceTestSuite[cfgType]) SetConfigCases(configCases map[string]ConfigCase[cfgType])
SetConfigCases sets the list of ConfigCase tests
func (*ResourceTestSuite[cfgType]) SetInCases ¶
func (s *ResourceTestSuite[cfgType]) SetInCases(inCases map[string]InCase[cfgType])
SetInCases sets the list of InCase tests
func (*ResourceTestSuite[cfgType]) SetOutCases ¶
func (s *ResourceTestSuite[cfgType]) SetOutCases(outCases map[string]OutCase[cfgType])
SetOutCases sets the list of OutCase tests
func (*ResourceTestSuite[cfgType]) SetupSuite ¶
func (s *ResourceTestSuite[cfgType]) SetupSuite()
func (*ResourceTestSuite[cfgType]) TestCheck ¶
func (s *ResourceTestSuite[cfgType]) TestCheck()
func (*ResourceTestSuite[cfgType]) TestConfig ¶
func (s *ResourceTestSuite[cfgType]) TestConfig()
func (*ResourceTestSuite[cfgType]) TestIn ¶
func (s *ResourceTestSuite[cfgType]) TestIn()
func (*ResourceTestSuite[cfgType]) TestOut ¶
func (s *ResourceTestSuite[cfgType]) TestOut()