rtestutils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Overview

Package rtestutils provides utilities for testing with resource API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAll

func AssertAll[R ResourceWithRD](ctx context.Context, t *testing.T, st state.State, assertionFunc func(r R, assertion *assert.Assertions), opts ...Option)

AssertAll asserts on all resources of a kind.

func AssertLength added in v0.3.10

func AssertLength[R ResourceWithRD](ctx context.Context, t *testing.T, st state.State, expectedLength int, opts ...Option)

AssertLength asserts on the length of a resource list.

func AssertNoResource

func AssertNoResource[R ResourceWithRD](
	ctx context.Context,
	t *testing.T,
	st state.State,
	id resource.ID,
	opts ...Option,
)

AssertNoResource asserts that a resource no longer exists.

func AssertResource added in v0.3.14

func AssertResource[R ResourceWithRD](
	ctx context.Context,
	t *testing.T,
	st state.State,
	id resource.ID,
	assertionFunc func(r R, assertion *assert.Assertions),
	opts ...Option,
)

AssertResource asserts on a resource. Doesn't use watch kind.

func AssertResources

func AssertResources[R ResourceWithRD](
	ctx context.Context,
	t *testing.T,
	st state.State,
	ids []resource.ID,
	assertionFunc func(r R, assertion *assert.Assertions),
	opts ...Option,
)

AssertResources asserts on a resource list.

func Destroy

func Destroy[R ResourceWithRD](ctx context.Context, t *testing.T, st state.State, ids []string)

Destroy performs graceful teardown/destroy sequence for specified IDs.

func DestroyAll

func DestroyAll[R ResourceWithRD](ctx context.Context, t *testing.T, st state.State)

DestroyAll performs graceful teardown/destroy sequence for all resources of type.

func ResourceIDs

func ResourceIDs[R ResourceWithRD](ctx context.Context, t *testing.T, st state.State, options ...state.ListOption) []resource.ID

ResourceIDs returns a list of resource IDs.

func ResourceIDsWithOwner

func ResourceIDsWithOwner[R ResourceWithRD](ctx context.Context, t *testing.T, st state.State, owner *string, options ...state.ListOption) []resource.ID

ResourceIDsWithOwner returns a list of resource IDs and filters them by owner (if set).

func Teardown added in v0.3.0

func Teardown[R ResourceWithRD](ctx context.Context, t *testing.T, st state.State, ids []string) []string

Teardown moves provided resources to the PhaseTearingDown.

Teardown ignores not found resources and returns a list of resources that were actually torn down.

Types

type Option added in v0.3.0

type Option func(*Options)

Option is a functional option for the test utils.

func WithNamespace added in v0.3.0

func WithNamespace(namespace string) Option

WithNamespace sets the namespace for the test utils.

func WithReportInterval added in v0.3.10

func WithReportInterval(interval time.Duration) Option

WithReportInterval controls the report interval for the test utils.

type Options added in v0.3.0

type Options struct {
	Namespace      string
	ReportInterval time.Duration
}

Options is a set of options for the test utils.

type ResourceWithRD

type ResourceWithRD = meta.ResourceWithRD

ResourceWithRD is an alias for meta.ResourceWithRD.

Jump to

Keyboard shortcuts

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