testcontroller

package
v1.116.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEventNotRecordedforUnstruct

func AssertEventNotRecordedforUnstruct(t *testing.T, c client.Client, unstruct *unstructured.Unstructured, reason string)

func AssertEventRecordedForObjectMetaAndKind

func AssertEventRecordedForObjectMetaAndKind(t *testing.T, c client.Client, kind string, om *metav1.ObjectMeta, reason string)

func AssertEventRecordedforUnstruct

func AssertEventRecordedforUnstruct(t *testing.T, c client.Client, unstruct *unstructured.Unstructured, reason string)

func AssertLabelsMatchAndHaveManagedLabel

func AssertLabelsMatchAndHaveManagedLabel(t *testing.T, actual, expected map[string]string)

AssertLabelsMatchAndHaveManagedLabel checks that a given label appears in the label map.

func AssertObservedGenerationEquals

func AssertObservedGenerationEquals(t *testing.T, unstruct *unstructured.Unstructured, preReconcileGeneration int64)

func AssertReadyCondition

func AssertReadyCondition(t *testing.T, object runtime.Object, minObservedGeneration int64)

AssertReadyCondition checks that the given status.conditions slice contains a Ready condition. It waits for the specified observedGeneration (or later).

func AssertServerGeneratedResourceIDMatch

func AssertServerGeneratedResourceIDMatch(t *testing.T, reconciledResourceID string, appliedUnstruct *unstructured.Unstructured)

func AssertUserSpecifiedResourceIDMatch

func AssertUserSpecifiedResourceIDMatch(t *testing.T, reconciledResourceID string, appliedUnstruct *unstructured.Unstructured)

func CollectEvents

func CollectEvents(t *testing.T, config *rest.Config, namespace string, expectedCount int, timeout time.Duration) []v1.Event

Collects an expected number of events from the API server. The timeout is applied on a per-event basis, so it is possible this function takes upwards of expectedCount * timeoutSeconds duration to 'timeout'. When a timeout does occur, t.Fatal(...) is invoked.

func DeleteAllEventsForUnstruct

func DeleteAllEventsForUnstruct(t *testing.T, c client.Client, unstruct *unstructured.Unstructured)

func EnsureNamespaceExists

func EnsureNamespaceExists(c client.Client, name string) error

func EnsureNamespaceExistsT

func EnsureNamespaceExistsT(t *testing.T, c client.Client, name string)

func EnsureNamespaceHasProjectIDAnnotation

func EnsureNamespaceHasProjectIDAnnotation(t *testing.T, c client.Client, namespaceName, projectID string)

func GetResourceID

func GetResourceID(t *testing.T, resourceUnstruct *unstructured.Unstructured) (string, bool)

func IsResourceIDFieldServerGenerated

func IsResourceIDFieldServerGenerated(rc *v1alpha1.ResourceConfig) bool

TODO(kcc-eng): Clean up all the duplicate IsResourceIDFieldServerGenerated functions.

func Name

func Name(t *testing.T) string

Name returns a suitable name for an object based on the test name.

func RemoveResourceID

func RemoveResourceID(u *unstructured.Unstructured)

func ReplaceTestVars

func ReplaceTestVars(t *testing.T, b []byte, uniqueID string, project testgcp.GCPProject) []byte

ReplaceTestVars replaces all occurrences of placeholder strings e.g. ${uniqueId} in a given byte slice.

func RunReconcilerAssertResults

func RunReconcilerAssertResults(ctx context.Context, t *testing.T, reconciler reconcile.Reconciler,
	kind string, objectMeta v1.ObjectMeta,
	expectedResult reconcile.Result, expectedErrorRegex *regexp.Regexp)

RunReconcilerAssertResults asserts the expected state of the reconciler run.

func SetResourceID

func SetResourceID(t *testing.T, u *unstructured.Unstructured, val string)

func SetupNamespaceForDefaultProject

func SetupNamespaceForDefaultProject(t *testing.T, c client.Client, name string)

func SetupNamespaceForProject

func SetupNamespaceForProject(t *testing.T, c client.Client, name, projectID string)

func StartMgr

func StartMgr(t *testing.T, mgr manager.Manager) func()

func StartTestManagerInstance

func StartTestManagerInstance(env *envtest.Environment, testType test.Type, whCfgs []cnrmwebhook.Config) (manager.Manager, func())

StartTestManager begins a new test manager, and returns a function to gracefully shutdown.

func SupportsResourceIDField

func SupportsResourceIDField(rc *v1alpha1.ResourceConfig) bool

TODO(kcc-eng): Clean up all the duplicate SupportsResourceIDField functions.

func UniqueName

func UniqueName(_ *testing.T, name string) string

UniqueName takes a name and returns a unique version.

func WaitForUnstructDeleteToFinish

func WaitForUnstructDeleteToFinish(t *testing.T, kubeClient client.Client, origUnstruct *unstructured.Unstructured)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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