Documentation
¶
Overview ¶
Package testfixtures collects test helpers shared across controller test packages. Six controllers' _test.go files each copied a near- identical mustCreate / eventually / hasTrueCondition trio (with 50/100/200 ms sleep deltas); centralizing here means a timing-flake fix is one edit instead of six.
Index ¶
- Constants
- func Eventually(t *testing.T, timeout time.Duration, fn func() bool)
- func HasCondition(conds []metav1.Condition, condType string, want metav1.ConditionStatus, ...) bool
- func HasConditionTrue(conds []metav1.Condition, condType string) bool
- func MustCreate(t *testing.T, c client.Client, o client.Object)
- func NewScheme(t *testing.T, extras ...func(*runtime.Scheme) error) *runtime.Scheme
Constants ¶
const PollInterval = 50 * time.Millisecond
PollInterval is the polling cadence for Eventually. Picked to match what the existing per-package helpers used most often (50ms).
Variables ¶
This section is empty.
Functions ¶
func Eventually ¶
Eventually polls fn until it returns true or the timeout elapses, failing the test if the timeout fires. Sleeps PollInterval between attempts.
func HasCondition ¶
func HasCondition(conds []metav1.Condition, condType string, want metav1.ConditionStatus, wantReason string) bool
HasCondition reports whether the named condition exists with the given status; an empty wantReason matches any reason. Replaces the per-type hasCondition / hasTrueCondition copies. Pass the CR-specific Status.Conditions slice — the helper is type-agnostic.
func HasConditionTrue ¶
HasConditionTrue is shorthand for HasCondition with status=True.
func MustCreate ¶
MustCreate t.Fatals on error. Replaces the per-package mustCreate copies (agentidentity, spiceboxclass, spiceboxsession, spiceboxtoolspec).
func NewScheme ¶
NewScheme builds a runtime.Scheme pre-registered with corev1 and the agentprimitives v1alpha1 group — the two scheme families every controller test in this repo needs. Extras (rbac, batch, etc.) can be appended for tests that touch additional APIs:
scheme := testfixtures.NewScheme(t, rbacv1.AddToScheme)
Registering an unused scheme is harmless, so the default fits even tests that only touch one of the two.
Types ¶
This section is empty.