Documentation
¶
Overview ¶
Package testutil provides assertion helpers for testing, wrapping testify's assert and require.
Index ¶
- func AssertPanic(t *testing.T, fn func(), msgAndArgs ...any)
- func Contains(t *testing.T, s, contains any, msgAndArgs ...any) bool
- func ElementsMatch(t *testing.T, listA, listB any, msgAndArgs ...any) bool
- func Equal(t *testing.T, expected, actual any, msgAndArgs ...any) bool
- func GreaterOrEqual(t *testing.T, e1, e2 any, msgAndArgs ...any) bool
- func NewFakeClient(objs ...runtime.Object) *fake.Clientset
- func NotNil(t *testing.T, object any, msgAndArgs ...any) bool
- func RequireContains(t *testing.T, s, contains any, msgAndArgs ...any)
- func RequireElementsMatch(t *testing.T, listA, listB any, msgAndArgs ...any)
- func RequireEqual(t *testing.T, expected, actual any, msgAndArgs ...any)
- func RequireError(t *testing.T, err error, msgAndArgs ...any)
- func RequireNoError(t *testing.T, err error, msgAndArgs ...any)
- func RequireNotNil(t *testing.T, object any, msgAndArgs ...any)
- type TestKubernetesClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertPanic ¶
AssertPanic asserts that fn panics.
func ElementsMatch ¶
ElementsMatch asserts that two slices contain the same elements, regardless of order.
func Equal ¶
Equal asserts that expected and actual are equal.
Parameters:
- t: the testing.T instance
- expected: the expected value
- actual: the actual value
- msgAndArgs: optional message and arguments
Returns:
- bool: true if equal, false otherwise
func GreaterOrEqual ¶
GreaterOrEqual asserts that e1 is greater than or equal to e2.
func NewFakeClient ¶
NewFakeClient returns a fake Kubernetes Clientset pre-loaded with the given objects.
func RequireContains ¶
RequireContains requires that s contains contains.
func RequireElementsMatch ¶
RequireElementsMatch requires that two slices contain the same elements, regardless of order.
func RequireEqual ¶
RequireEqual requires that expected and actual are equal.
func RequireError ¶
RequireError requires that err is not nil.
func RequireNoError ¶
RequireNoError requires that err is nil.
Types ¶
type TestKubernetesClient ¶
type TestKubernetesClient interface {
CoreV1NodesList(ctx context.Context, opts v1.ListOptions) ([]corev1.Node, error)
CoreV1PodsList(ctx context.Context, namespace string, opts v1.ListOptions) ([]corev1.Pod, error)
}
TestKubernetesClient is a minimal interface for test fakes.
func NewFakeKubernetesClientAdapter ¶
func NewFakeKubernetesClientAdapter(clientset *fake.Clientset) TestKubernetesClient
NewFakeKubernetesClientAdapter returns a TestKubernetesClient for testing.