assertion

package
v0.0.0-...-0d68d12 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

The assertion package provides common functionality used to define assertions against a set of one or more Kubernetes resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsFeature

func AsFeature(assert Assertion) features.Feature

AsFeature returns an e2e-framework Feature based on the supplied Assertion. This can be used to integrate Assertions into existing e2e-framework tests.

Types

type Assertion

type Assertion interface {

	// GetLabels returns the labels (i.e. metadata.labels) used to select resources for the assertion.
	GetLabels() map[string]string

	// GetFields returns the fields used to select resources for the assertion.
	GetFields() map[string]string

	// GetListOptions returns the ListOptions used to when listing resources from the API server.
	ListOptions(cfg *envconf.Config) metav1.ListOptions

	// GetInterval returns the interval used when polling for the assertion to be true.
	GetInterval() time.Duration

	// GetTimeout returns the timeout used when polling for the assertion to be true.
	GetTimeout() time.Duration

	// GetBuilder returns the features.FeatureBuilder used to build the e2e-framework Feature.
	GetBuilder() *features.FeatureBuilder

	// SetBuilder sets the features.FeatureBuilder used to build the e2e-framework Feature.
	SetBuilder(builder *features.FeatureBuilder)

	// GetRequireT returns the require.TestingT used to report test failures. This is largely intended for testing
	// as it enables detection of failing require/assert statements.
	GetRequireT() require.TestingT
	// contains filtered or unexported methods
}

Assertion is an interface for a generic assertion (har) about the state of one or more resources in a Kubernetes cluster. It is embedded into other assertion types to provide common functionality.

func Clone

func Clone(a Assertion) Assertion

Clone clones an assertion. This is done this way instead of providing an exported Clone method in order to avoid having the Clone method exported on all assertion types.

func NewAssertion

func NewAssertion(opts ...Option) Assertion

NewAssertion creates a new Assertion with the provided options.

type Option

type Option func(Assertion)

Option is a function that configures one or more facets of an Assertion.

func WithBuilder

func WithBuilder(builder *features.FeatureBuilder) Option

WithBuilder sets the features.FeatureBuilder used to build the e2e-framework Feature.

func WithInterval

func WithInterval(interval time.Duration) Option

WithInterval sets the interval used when polling for the assertion to be true.

func WithRequireT

func WithRequireT(requireT require.TestingT) Option

WithRequireT sets the require.TestingT used to report test failures.

func WithResourceFields

func WithResourceFields(fields map[string]string) Option

WithResourceFields sets the fields to be used when selecting resources for the assertion.

func WithResourceLabels

func WithResourceLabels(labels map[string]string) Option

WithResourceLabels sets the labels to be used when selecting resources for the assertion.

func WithResourceName

func WithResourceName(name string) Option

WithResourceName sets the name (i.e. metadata.name) to be used when selecting resources for the assertion.

func WithResourceNamespace

func WithResourceNamespace(namespaceName string) Option

WithResourceNamespace sets the namespace to be used when selecting resources for the assertion.

func WithResourceNamespaceFromTestEnv

func WithResourceNamespaceFromTestEnv() Option

WithResourceNamespaceFromTestEnv sets the namespace to be used when selecting resources for the assertion to the namespace set in the test environment.

func WithSetup

func WithSetup(steps ...e2etypes.StepFunc) Option

WithSetup adds setup steps to the assertion.

func WithTeardown

func WithTeardown(steps ...e2etypes.StepFunc) Option

WithTeardown adds teardown steps to the assertion.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout used when polling for the assertion to be true.

Jump to

Keyboard shortcuts

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