test

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertManifestExistence

func AssertManifestExistence(
	ctx context.Context,
	c client.Client,
	manifestYAML string,
	timeout time.Duration,
	pollingInterval time.Duration,
)

AssertManifestExistence asserts the existence of all objects in a YAML manifest on the kube-apiserver referenced by the given client. Does not check object data.

func AssertOwnerRef

func AssertOwnerRef(o client.Object, owner client.Object, scheme *runtime.Scheme)

AssertOwnerRef asserts that the provided object has an owner reference that references the provided owner.

func AssertOwnerRefWithGomega

func AssertOwnerRefWithGomega(o client.Object, owner client.Object, scheme *runtime.Scheme, g gomega.Gomega)

AssertOwnerRefWithGomega is the same as AssertOwnerRef but accepts a Gomega instance, useful for using inside Eventually/Consistently blocks.

func AssertRedditLabels

func AssertRedditLabels(o client.Object, controllerName string)

AssertRedditLabels asserts expected Reddit labels on the provided object.

func AssertRedditLabelsWithGomega

func AssertRedditLabelsWithGomega(o client.Object, controllerName string, g gomega.Gomega)

AssertRedditLabelsWithGomega is the same as AssertRedditLabels but accepts a Gomega instance, useful for using inside Eventually/Consistently blocks.

func ConditionsEqual

func ConditionsEqual(c, other api.Condition) bool

ConditionsEqual compares two api.Condition structs for equality. It mimics the behavior of api.Condition.Equal, but does not compare the ObservedGeneration field.

func ExternalCRDDirectoryPaths

func ExternalCRDDirectoryPaths(pkgToCRDDir map[string][]string, rootDir string) ([]string, error)

ExternalCRDDirectoryPaths returns a list of paths of CRD directories given a mapping of pkg names to relative CRD directories

func GenerateRandomString

func GenerateRandomString(length int) string

func KubeConfigBytesFromREST

func KubeConfigBytesFromREST(cfg *rest.Config) ([]byte, error)

KubeConfigBytesFromREST reverse-engineers a kubeconfig file from a rest.Config. The options are tailored towards the rest.Configs we generate, so they're not broadly applicable.

This is not intended to be exposed beyond internal for the above reasons.

func KubeConfigFromREST

func KubeConfigFromREST(cfg *rest.Config) (*kcapi.Config, error)

func MatchConditionedStatus

func MatchConditionedStatus(expected interface{}) types.GomegaMatcher

MatchConditionedStatus uses custom equality logic for the ConditionedStatus field, and reflect.DeepEqual for all other fields.

func ModuleDir

func ModuleDir(pkg string, rootDir string) (string, error)

ModuleDir returns the absolute path for the module containing the provided package.

func MustParseBool

func MustParseBool(envVarName string) bool

func NewReadyConditionForTest

func NewReadyConditionForTest(conditions ...api.Condition) api.Condition

NewReadyConditionForTest creates a new Ready condition for testing purposes. It sets the observed generation to 0.

func NewReadyConditionForTestWithObservedGeneration

func NewReadyConditionForTestWithObservedGeneration(obsGen int64, conditions ...api.Condition) api.Condition

NewReadyConditionForTestWithObservedGeneration creates a new Ready condition for testing purposes. It sets the observed generation to the provided value.

Types

type ClientFilter

type ClientFilter interface {
	Filter(event string, obj client.Object) error
}

type EnvTestBuilder

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

func NewEnvTestBuilder

func NewEnvTestBuilder(ctx context.Context) *EnvTestBuilder

func (*EnvTestBuilder) Start

func (b *EnvTestBuilder) Start() (_ *TestEnv, rerr error)

Start starts the test environment. The caller must call TestEnv.Stop to shut down the environment.

func (*EnvTestBuilder) WithCRDDirectoryPaths

func (b *EnvTestBuilder) WithCRDDirectoryPaths(paths []string) *EnvTestBuilder

func (*EnvTestBuilder) WithKubeConfigFile

func (b *EnvTestBuilder) WithKubeConfigFile(path string) *EnvTestBuilder

WithKubeConfigFile enables writing the envtest kube-apiserver kubeconfig to a file at the given path

func (*EnvTestBuilder) WithLog

func (b *EnvTestBuilder) WithLog(log *zap.Logger) *EnvTestBuilder

WithLog overrides the default logger used with the controller manager.

func (*EnvTestBuilder) WithManagerOpts

func (b *EnvTestBuilder) WithManagerOpts(opts ctrl.Options) *EnvTestBuilder

WithManagerOpts sets the manager options with which to initialize the manager.

func (*EnvTestBuilder) WithManagerSetupFns

func (b *EnvTestBuilder) WithManagerSetupFns(fns ...ManagerSetupFn) *EnvTestBuilder

func (*EnvTestBuilder) WithManagerUser

func (b *EnvTestBuilder) WithManagerUser(user envtest.User) *EnvTestBuilder

WithManagerUser sets the Kubernetes user that the manager is authorized as

func (*EnvTestBuilder) WithScheme

func (b *EnvTestBuilder) WithScheme(scheme *runtime.Scheme) *EnvTestBuilder

WithScheme sets the scheme that will be used for the client and manager (if enabled)

func (*EnvTestBuilder) WithWebhookConfigs

func (b *EnvTestBuilder) WithWebhookConfigs(configPaths ...string) *EnvTestBuilder

WithWebhookConfigs wires up validating or mutating admission webhook configurations specified by the resources residing in the provided path.

type FilterFn

type FilterFn func(event string, obj client.Object) error

func (FilterFn) Filter

func (f FilterFn) Filter(event string, obj client.Object) error

type FilteringClient

type FilteringClient struct {
	client.WithWatch
	// contains filtered or unexported fields
}

func NewFilteringClient

func NewFilteringClient(c client.WithWatch, f ...ClientFilter) *FilteringClient

func (*FilteringClient) Create

func (c *FilteringClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

func (*FilteringClient) Status

func (*FilteringClient) Update

func (c *FilteringClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

type ManagerSetupFn

type ManagerSetupFn func(mgr manager.Manager) error

type TestEnv

type TestEnv struct {
	TestEnv *envtest.Environment
	Mgr     manager.Manager
	Client  client.Client
	Cfg     *rest.Config
	// contains filtered or unexported fields
}

func (*TestEnv) Stop

func (e *TestEnv) Stop() error

Jump to

Keyboard shortcuts

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