envtest

package
v0.20.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneNameNamespace added in v0.13.0

func CloneNameNamespace[T any, PT interface {
	*T
	client.Object
}](obj PT,
) PT

CloneNameNamespace returns an empty client object of the same type with the same and namespace. This is a helper to pass a new object to the "Eventually" methods while preserving the original object's data.

func CreateObjs added in v0.12.0

func CreateObjs(ctx context.Context, t testing.TB, c client.Client, objs ...client.Object)

CreateObjs creates Objects using the provided kube client and waits until its cache has been updated with those objects.

func RunWithEnvironment

func RunWithEnvironment(m *testing.M, opts ...EnvironmentOpt) int

RunWithEnvironment runs a suite of tests with an envtest that is shared across all tests We use testing.M as the input to avoid having this called directly from a test This ensures the envtest setup is always run from a TestMain.

func UpdateStatusAndWait added in v0.13.0

func UpdateStatusAndWait(ctx context.Context, t testing.TB, c client.Client, o client.Object)

UpdateStatusAndWait updates an objects status subresource and waits until the cache refreshes and reflects the new status.

Types

type APIExpecter added in v0.13.0

type APIExpecter struct {
	// contains filtered or unexported fields
}

APIExpecter is a helper to define eventual expectations over API resources in tests. It's useful when working with clients that maintain a cache, since changes might not be reflected immediately, causing tests to flake.

func NewAPIExpecter added in v0.13.0

func NewAPIExpecter(t testing.TB, client client.Client) *APIExpecter

NewAPIExpecter constructs a new APIExpecter.

func (*APIExpecter) DeleteAllOfAndWait added in v0.13.0

func (a *APIExpecter) DeleteAllOfAndWait(ctx context.Context, obj client.Object)

DeleteAllOfAndWait deletes all objects of the given type and waits until the client's cache reflects those changes.

func (*APIExpecter) DeleteAndWait added in v0.13.0

func (a *APIExpecter) DeleteAndWait(ctx context.Context, objs ...client.Object)

DeleteAndWait sends delete requests for a collection of objects and waits until the client cache reflects the changes.

func (*APIExpecter) ShouldEventuallyExist added in v0.13.0

func (a *APIExpecter) ShouldEventuallyExist(ctx context.Context, obj client.Object)

ShouldEventuallyExist defines an eventual expectation that succeeds if the provided object becomes readable by the client before the timeout expires.

func (*APIExpecter) ShouldEventuallyMatch added in v0.13.0

func (a *APIExpecter) ShouldEventuallyMatch(ctx context.Context, obj client.Object, match func(g gomega.Gomega))

ShouldEventuallyMatch defines an eventual expectation that succeeds if the provided object becomes readable by the client and matches the provider expectation before the timeout expires.

func (*APIExpecter) ShouldEventuallyNotExist added in v0.13.0

func (a *APIExpecter) ShouldEventuallyNotExist(ctx context.Context, obj client.Object)

ShouldEventuallyNotExist defines an eventual expectation that succeeds if the provided object becomes not found by the client before the timeout expires.

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

func (*Environment) APIReader

func (e *Environment) APIReader() client.Reader

APIReader returns a non cached reader client.

func (*Environment) Client

func (e *Environment) Client() client.Client

func (*Environment) CreateNamespaceForTest

func (e *Environment) CreateNamespaceForTest(ctx context.Context, t *testing.T) string

func (*Environment) Manager added in v0.9.2

func (e *Environment) Manager() manager.Manager

Manager returns a Manager for the test environment.

type EnvironmentOpt

type EnvironmentOpt func(ctx context.Context, e *Environment)

func WithAssignment

func WithAssignment(envRef **Environment) EnvironmentOpt

Jump to

Keyboard shortcuts

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