Documentation
¶
Overview ¶
assertionhelpers contains functionality that aids in the creation and use of assertions.
Index ¶
- func ApplyKustomization(kustDir string) env.Func
- func CreateResourceFromPath(resourcePath string, decoderOpts ...decoder.DecodeOption) e2etypes.StepFunc
- func CreateResourceFromPathWithNamespaceFromEnv(resourcePath string, decoderOpts ...decoder.DecodeOption) e2etypes.StepFunc
- func DeleteResourceFromPath(resourcePath string, decoderOpts ...decoder.DecodeOption) e2etypes.StepFunc
- func DynamicClientFromEnvconf(t require.TestingT, cfg *envconf.Config) *dynamic.DynamicClient
- func RequireTIfNotNil(testingT *testing.T, requireT require.TestingT) require.TestingT
- func Sleep(sleepTime time.Duration) e2etypes.StepFunc
- func TestAssertions(t *testing.T, testEnv env.Environment, assertions ...assertion.Assertion)
- func WaitForCondition(ctx context.Context, assert assertion.Assertion, ...) error
- type ConditionFunc
- type ConditionFuncFactory
- type IntCompareFunc
- type StepFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyKustomization ¶
ApplyKustomization applies a kustomization at the provided directory.
TODO: refactor this function to be more testable and also simpler
func CreateResourceFromPath ¶
func CreateResourceFromPath(resourcePath string, decoderOpts ...decoder.DecodeOption) e2etypes.StepFunc
CreateResourceFromPath creates a resource from a file at the provided path.
func CreateResourceFromPathWithNamespaceFromEnv ¶
func CreateResourceFromPathWithNamespaceFromEnv( resourcePath string, decoderOpts ...decoder.DecodeOption, ) e2etypes.StepFunc
CreateResourceFromPathWithNamespaceFromEnv creates a resource from a file at the provided path and sets the resource's namespace to the one provided in the environment configuration.
func DeleteResourceFromPath ¶
func DeleteResourceFromPath(resourcePath string, decoderOpts ...decoder.DecodeOption) e2etypes.StepFunc
DeleteResourceFromPath deletes a resource from a file at the provided path.
func DynamicClientFromEnvconf ¶
DynamicClientFromEnvconf creates a dynamic client from the environment configuration.
func RequireTIfNotNil ¶
RequireTIfNotNil returns the require.TestingT object if it is not nil, otherwise it returns the provided testing.T object. This is primarily intended to enable injection of a mock for testing assertion code fails as expected.
func TestAssertions ¶
TestAssertions tests the provided assertions.
func WaitForCondition ¶
func WaitForCondition( ctx context.Context, assert assertion.Assertion, conditionFunc apimachinerywait.ConditionWithContextFunc, ) error
WaitForCondition waits for a conditionFunc to be satisfied (i.e. return true) based on the timeout and interval set on the Assertion.
Types ¶
type ConditionFunc ¶
type ConditionFunc = apimachinerywait.ConditionWithContextFunc
ConditionFunc is a function that returns a boolean based on a condition being satisfied.
type ConditionFuncFactory ¶
type ConditionFuncFactory = func( require.TestingT, assertion.Assertion, *envconf.Config, int, IntCompareFunc, IntCompareFunc, ) ConditionFunc
ConditionFuncFactory is a function that returns a ConditionFunc.
type IntCompareFunc ¶
IntCompareFunc is a function that compares two integers and returns a boolean.
var ( // IntCompareFuncLessThan is a function that compares two integers and returns true if the first integer is less // than the second. IntCompareFuncLessThan IntCompareFunc = func(a, b int) bool { return a < b } // IntCompareFuncLessThanOrEqualTo is a function that compares two integers and returns true if the first integer is // less than or equal to the second. IntCompareFuncLessThanOrEqualTo IntCompareFunc = func(a, b int) bool { return a <= b } // IntCompareFuncEqualTo is a function that compares two integers and returns true if the first integer is equal to // the second. IntCompareFuncEqualTo IntCompareFunc = func(a, b int) bool { return a == b } // IntCompareFuncGreaterThan is a function that compares two integers and returns true if the first integer is // greater than the second. IntCompareFuncGreaterThan IntCompareFunc = func(a, b int) bool { return a > b } // IntCompareFuncGreaterThanOrEqualTo is a function that compares two integers and returns true if the first integer // is greater than or equal to the second. IntCompareFuncGreaterThanOrEqualTo IntCompareFunc = func(a, b int) bool { return a >= b } // IntCompareFuncNotEqualTo is a function that compares two integers and returns true if the first integer is not // equal to the second. IntCompareFuncNotEqualTo IntCompareFunc = func(a, b int) bool { return a != b } )
type StepFunc ¶
StepFunc is a function that performs a step in a test.
func AsStepFunc ¶
func AsStepFunc( assert assertion.Assertion, conditionFactory ConditionFuncFactory, count int, itemCountFn, resultFn IntCompareFunc, ) StepFunc
AsStepFunc returns a StepFunc that waits for a condition to be satisfied based on the provided ConditionFuncFactory. The count parameter is used to determine the number of resources that should satisfy the condition. The itemCountFn parameter is used to evalute the number of resources under consideration to satisfy the condition. The resultFn is used to evaluate the number of items that satisfy the condition relative to the count.