testutils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DurationEpsilon = 3 * time.Second

DurationEpsilon is the difference between two times which we still see as equal. This is useful when tests want to check if the requeue is at the correct point in time, while still allowing for a bit of deviation because of host load.

Variables

View Source
var DoNotDeleteFinalizerName = "ctf.backbone81/do-not-delete"

DoNotDeleteFinalizerName provides a name for a finalizer which is not used by the reconcilers themselves. This finalizer is used to prevent a resource from being deleted immediately when you want to test situations where you need to inspect the behavior for deletion.

Functions

func GenerateName

func GenerateName(prefix string) string

GenerateName simulates the behavior of Kubernetes GenerateName for test situations where we need to know the name beforehand.

func MakeBinDirAvailable

func MakeBinDirAvailable() error

MakeBinDirAvailable adds the bin subdirectory of the current working directory to the PATH environment variable. This is helpful when debugging tests, because some IDEs make it hard to extend the PATH environment variable through their project configuration.

func MoveToProjectRoot

func MoveToProjectRoot() error

MoveToProjectRoot changes the current working directory to the root of the project. This is helpful for running tests, which are executed with the working directory set to the directory the test resides in. This makes it difficult to reference files from other directories. MoveToProjectRoot moves up in the directory tree until it finds the go.mod.

func PrependToPath

func PrependToPath(directory string) error

PrependToPath prepends the given directory to the PATH environment variable.

func RequestFromObject

func RequestFromObject(obj client.Object) reconcile.Request

RequestFromObject constructs a reconcile request for the given object.

func SetupTestEnv

func SetupTestEnv() (*envtest.Environment, client.Client)

SetupTestEnv prepares envtest and a kubernetes client for interacting with the envtest instance. The client is uncached.

Types

This section is empty.

Jump to

Keyboard shortcuts

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