testfixtures

package
v0.0.0-...-2769864 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
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

func Eventually(t *testing.T, timeout time.Duration, fn func() bool)

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

func HasConditionTrue(conds []metav1.Condition, condType string) bool

HasConditionTrue is shorthand for HasCondition with status=True.

func MustCreate

func MustCreate(t *testing.T, c client.Client, o client.Object)

MustCreate t.Fatals on error. Replaces the per-package mustCreate copies (agentidentity, spiceboxclass, spiceboxsession, spiceboxtoolspec).

func NewScheme

func NewScheme(t *testing.T, extras ...func(*runtime.Scheme) error) *runtime.Scheme

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL