testresource

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureTestDependencies

func EnsureTestDependencies(tb testing.TB, ctx context.Context, testMode TestMode) context.Context

When running the go tests directly, the 'make' environment variables are not available, so here we run 'make' from go to generate all dependencies through make and set the correct environment variables.

func RequireValue

func RequireValue(tb testing.TB, key string) string

Require a dependency value to be set and return the value. These values are all provided by make and passed to golang using files in the envsDir folder.

Types

type CompleteFunc

type CompleteFunc func(fn func(runtime.Object) error, eventTypes ...watch.EventType) error

type OwnedKubeClients

type OwnedKubeClients struct {
	EnvTest    *envtest.Environment
	Rest       *rest.Config
	Scheme     *runtime.Scheme
	KubeClient *kubernetes.Clientset
	Client     client.WithWatch
}

func KubeClients

func KubeClients(tb testing.TB, ctx context.Context) *OwnedKubeClients

func (*OwnedKubeClients) InstallCRDs

func (*OwnedKubeClients) SetupNamespace

func (k *OwnedKubeClients) SetupNamespace(tb testing.TB, ctx context.Context) (string, context.CancelFunc)

func (*OwnedKubeClients) StartObjectWatch

func (k *OwnedKubeClients) StartObjectWatch(
	tb testing.TB,
	ctx context.Context,
	object client.Object,
) CompleteFunc

StartObjectWatch starts a watch for the provided object, the returned function should be used to wait for a condition to succeed. The watch will start after calling this function. This means that the completion function can respond to events received before calling the complete function but after calling StartObjectWatch.

type TestMode

type TestMode string
const (
	UnknownTest  TestMode = "UNKNOWN"
	UnitTest     TestMode = "UNIT"
	EndToEndTest TestMode = "E2E"
)

func CurrentTestMode

func CurrentTestMode(ctx context.Context) TestMode

Extract from the context what the test mode is of the current test. If value is not set, 'UnknownTest' is returned.

Jump to

Keyboard shortcuts

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