testutils

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MPL-2.0 Imports: 37 Imported by: 1

Documentation

Index

Constants

View Source
const BaseURI = "https://weave.works/api"

Variables

This section is empty.

Functions

func DeleteAllOf added in v0.8.0

func DeleteAllOf(g *gomega.GomegaWithT, obj client.Object)

DeleteAllOf loops through all namespaces and deletes all resources from the given type

func DeleteNamespace added in v0.8.0

func DeleteNamespace(g *gomega.GomegaWithT, ns *corev1.Namespace)

DeleteNamespace deletes a namespace. Note: deleting a namespace using this function on tests wont delete the underlying resources like in a real environment would.

func MakeFakeLogr added in v0.3.0

func MakeFakeLogr() (logr.Logger, *fakelogr.LogSink)

MakeFakeLogr returns an API compliant logr object that can be used for unit testing.

func MakeJWToken added in v0.6.1

func MakeJWToken(t *testing.T, key *rsa.PrivateKey, email string, opts ...func(map[string]any)) string

MakeJWToken creates and signs a token with the provided key.

func MakeKeysetServer added in v0.6.1

func MakeKeysetServer(t *testing.T, key *rsa.PrivateKey) *httptest.Server

MakeKeysetServer starts an HTTP server that can serve JSONWebKey sets.

func MakeRSAPrivateKey added in v0.6.1

func MakeRSAPrivateKey(t *testing.T) *rsa.PrivateKey

MakeRSAPrivateKey generates and returns an RSA Private Key.

func MatchGRPCError added in v0.7.0

func MatchGRPCError(code, err interface{}) types.GomegaMatcher

func Setenv added in v0.5.0

func Setenv(k, v string) func()

Types

type K8sTestEnv

type K8sTestEnv struct {
	Env        *envtest.Environment
	Client     client.Client
	DynClient  dynamic.Interface
	RestMapper *restmapper.DeferredDiscoveryRESTMapper
	Rest       *rest.Config
	Stop       func()
}

func StartK8sTestEnvironment

func StartK8sTestEnvironment(crdPaths []string) (*K8sTestEnv, error)

Note that crdPaths are relative to the path of the test file, NOT the current working directory or path that the tests were started from.

Jump to

Keyboard shortcuts

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