testing

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package testing contains test helpers for reconcilers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eventf

func Eventf(eventtype, reason, messageFmt string, args ...interface{}) string

Eventf returns the attributes of an API event in the format returned by Kubernetes' FakeRecorder.

func MakeFactory

func MakeFactory(ctor Ctor) rt.Factory

MakeFactory creates a testing factory for our controller.Reconciler, and initializes a Reconciler using the given Ctor as part of the process.

func NewConfigMap

func NewConfigMap(name string, data map[string]string) *corev1.ConfigMap

NewConfigMap returns a ConfigMap object.

func NewScheme

func NewScheme() *runtime.Scheme

NewScheme returns a new scheme populated with the types defined in clientSetSchemes.

func TestControllerConstructor

func TestControllerConstructor(t *testing.T, ctor injection.ControllerConstructor, opts ...ControllerTestOptions)

TestControllerConstructor tests that a controller constructor meets our requirements.

func TestControllerConstructorFailures

func TestControllerConstructorFailures(t *testing.T, ctor injection.ControllerConstructor)

TestControllerConstructorFailures tests that a controller constructor fails when various requirements are not met.

func ToUnstructured added in v1.14.1

func ToUnstructured(t *testing.T, objs []runtime.Object) (unstr []runtime.Object)

ToUnstructured takes a list of k8s resources and converts them to Unstructured objects. We must pass objects as Unstructured to the dynamic client fake, or it won't handle them properly.

Types

type ControllerTestOptions

type ControllerTestOptions func(*constructorTestConfig)

ControllerTestOptions is a functional option for a constructorTestConfig.

func WithInformerNumber

func WithInformerNumber(n int) ControllerTestOptions

WithInformerNumber sets the number of expected informers for the test

type Ctor

Ctor constructs a controller.Reconciler.

type FakeOwnerRefable

type FakeOwnerRefable struct {
	metav1.ObjectMeta
	schema.GroupVersionKind
}

FakeOwnerRefable implements OwnerRefable.

func NewOwnerRefable

func NewOwnerRefable(name string, gvk schema.GroupVersionKind, uid types.UID) *FakeOwnerRefable

NewOwnerRefable returns a OwnerRefable with the given attributes.

func (*FakeOwnerRefable) GetGroupVersionKind

func (o *FakeOwnerRefable) GetGroupVersionKind() schema.GroupVersionKind

GetGroupVersionKind returns the GroupVersionKind from the object.

type Listers

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

Listers returns listers and objects filtered from those listers.

func NewListers

func NewListers(scheme *runtime.Scheme, objs []runtime.Object) Listers

NewListers returns a new instance of Listers initialized with the given objects.

func (*Listers) GetKubeObjects

func (l *Listers) GetKubeObjects() []runtime.Object

GetKubeObjects returns objects from the targets API.

func (*Listers) GetServiceLister

func (l *Listers) GetServiceLister() servinglistersv1.ServiceLister

GetServiceLister returns a lister for Service objects.

func (*Listers) GetServingObjects

func (l *Listers) GetServingObjects() []runtime.Object

GetServingObjects returns objects from the serving API.

func (*Listers) GetXSLTTransformationLister added in v1.14.1

func (l *Listers) GetXSLTTransformationLister() flowlisters.XSLTTransformationLister

GetXSLTTransformationLister returns a Lister for GoogleSheetTarget objects.

func (*Listers) GetXSLTTransformationObjects added in v1.14.1

func (l *Listers) GetXSLTTransformationObjects() []runtime.Object

GetXSLTTransformationObjects returns objects from the TriggerMesh API.

func (*Listers) IndexerFor

func (l *Listers) IndexerFor(obj runtime.Object) cache.Indexer

IndexerFor returns the indexer for the given object.

Jump to

Keyboard shortcuts

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