test

package
v0.0.0-...-da4181b Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErrorMatch

func AssertErrorMatch(t *testing.T, s string, e error)

AssertErrorMatch will fail if the error doesn't match the provided error.

func AssertInventoryHasItems

func AssertInventoryHasItems(t *testing.T, gs *templatesv1.GitOpsSet, objs ...runtime.Object)

AssertInventoryHasItems will ensure that each of the provided objects is listed in the Inventory of the provided GitOpsSet.

func AssertNoError

func AssertNoError(t *testing.T, err error)

AssertNoError will fail if the provided err value is an error.

func AssertNotFound

func AssertNotFound(t *testing.T, err error)

AssertNotFound will fail if the provided err value not a NotFound error from the K8s client API.

func MakeTestKustomization

func MakeTestKustomization(name types.NamespacedName, opts ...func(*kustomizev1.Kustomization)) *kustomizev1.Kustomization

func MatchErrorString

func MatchErrorString(t *testing.T, s string, e error) bool

MatchErrorString takes a string and matches on the error and returns true if the string matches the error.

This is useful in table tests.

If the string can't be compiled as an regexp, then this will fail with a Fatal error.

func NewConfigMap

func NewConfigMap(opts ...func(*corev1.ConfigMap)) *corev1.ConfigMap

NewConfigMap creates and returns a new ConfigMap.

func NewGitRepository

func NewGitRepository(opts ...func(*sourcev1.GitRepository)) *sourcev1.GitRepository

NewGitRepository creates and returns a new GitRepository.

func NewImagePolicy

func NewImagePolicy(opts ...func(*imagev1.ImagePolicy)) *imagev1.ImagePolicy

NewImagePolicy creates and returns a new Flux ImagePolicy.

func NewNamespace

func NewNamespace(name string, opts ...func(*corev1.Namespace)) *corev1.Namespace

NewNamespace creates a new namespace with the provided name.

func NewSecret

func NewSecret(opts ...func(*corev1.Secret)) *corev1.Secret

NewSecret creates and returns a new Secret.

func StartFakeArchiveServer

func StartFakeArchiveServer(t *testing.T, dir string) *httptest.Server

StartFakeArchiveServer starts an http server that serves the provided directory.

func ToUnstructured

func ToUnstructured(t *testing.T, obj runtime.Object) *unstructured.Unstructured

ToUnstructured converts a k8s Object to an Unstructured.

It also removes the "status" field from the Unstructured representation.

Types

type EventData

type EventData struct {
	EventType string
	Reason    string
	Message   string
}

EventData represents the data of a fake event used in tests

type FakeEventRecorder

type FakeEventRecorder struct {
	Events []*EventData
}

FakeEventRecorder is a fake event recorder used in tests to simulate recording the events in a slice of EventData

func (*FakeEventRecorder) Event

func (f *FakeEventRecorder) Event(object runtime.Object, eventtype, reason, message string)

Event records a new event in the slice of the fake event recorder used in a test The interface using Event is the EventRecorder interface

func (*FakeEventRecorder) Reset

func (f *FakeEventRecorder) Reset()

Reset resets the slice of the fake event recorder used in a test

Jump to

Keyboard shortcuts

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