testing

package
v0.26.4 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: Apache-2.0 Imports: 44 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeFactory added in v0.6.0

func MakeFactory(ctor Ctor, unstructured bool, logger *zap.SugaredLogger) Factory

MakeFactory creates a reconciler factory with fake clients and controller created by `ctor`.

func NewConfigMap added in v0.13.0

func NewConfigMap(name, namespace string, o ...ConfigMapOption) *v1.ConfigMap

NewConfigMap creates a new ConfigMap.

func NewCustomResourceDefinition added in v0.7.0

func NewCustomResourceDefinition(name string, o ...CustomResourceDefinitionOption) *apiextensionsv1.CustomResourceDefinition

NewCustomResourceDefinition creates a CustomResourceDefinition with CustomResourceDefinitionOption.

func NewDeployment added in v0.6.0

func NewDeployment(name, namespace string, do ...DeploymentOption) *appsv1.Deployment

NewDeployment creates a Deployment with DeploymentOptions.

func NewEndpoints added in v0.14.0

func NewEndpoints(name, namespace string, so ...EndpointsOption) *corev1.Endpoints

NewEndpoints creates a Endpoints with EndpointsOptions

func NewEventType added in v0.6.0

func NewEventType(name, namespace string, o ...EventTypeOption) *v1beta1.EventType

NewEventType creates a EventType with EventTypeOptions.

func NewNamespace added in v0.6.0

func NewNamespace(name string, o ...NamespaceOption) *corev1.Namespace

NewNamespace creates a Namespace with NamespaceOptions

func NewScheme added in v0.6.0

func NewScheme() *runtime.Scheme

func NewService added in v0.6.0

func NewService(name, namespace string, so ...ServiceOption) *corev1.Service

NewService creates a Service with ServiceOptions

func NewUnstructured added in v0.6.0

func NewUnstructured(gvk metav1.GroupVersionKind, name, namespace string, uo ...UnstructuredOption) *unstructured.Unstructured

NewUnstructured creates a unstructured.Unstructured with UnstructuredOption

func ToUnstructured added in v0.6.0

func ToUnstructured(t *testing.T, objs []runtime.Object) (us []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.

func WithEventTypeBrokerDoesNotExist added in v0.6.0

func WithEventTypeBrokerDoesNotExist(et *v1beta1.EventType)

WithEventTypeBrokerNotFound calls .Status.MarkFilterFailed on the EventType.

func WithEventTypeBrokerExists added in v0.6.0

func WithEventTypeBrokerExists(et *v1beta1.EventType)

WithEventTypeBrokerExists calls .Status.MarkBrokerExists on the EventType.

func WithEventTypeBrokerReady added in v0.6.0

func WithEventTypeBrokerReady(et *v1beta1.EventType)

WithEventTypeBrokerReady calls .Status.MarkBrokerReady on the EventType.

func WithEventTypeDeletionTimestamp added in v0.6.0

func WithEventTypeDeletionTimestamp(et *v1beta1.EventType)

func WithInitEventTypeConditions added in v0.6.0

func WithInitEventTypeConditions(et *v1beta1.EventType)

WithInitEventTypeConditions initializes the EventType's conditions.

func WithNamespaceDeleted added in v0.6.0

func WithNamespaceDeleted(n *corev1.Namespace)

Types

type Buildable

type Buildable interface {
	Build() runtime.Object
}

Buildable allows test fixtures to use the builder pattern. The table test runner will call Build() on any Buildable objects and use the result as the test fixture.

type ConfigMapOption added in v0.13.0

type ConfigMapOption func(*v1.ConfigMap)

ConfigMapOption enables further configuration of a ConfigMap.

func WithConfigMapData added in v0.13.0

func WithConfigMapData(data map[string]string) ConfigMapOption

func WithConfigMapLabels added in v0.13.0

func WithConfigMapLabels(labels metav1.LabelSelector) ConfigMapOption

type Ctor added in v0.6.0

Ctor functions create a k8s controller with given params.

type CustomResourceDefinitionOption added in v0.7.0

type CustomResourceDefinitionOption func(*apiextensionsv1.CustomResourceDefinition)

CustomResourceDefinitionOption enables further configuration of a CustomResourceDefinition.

func WithCustomResourceDefinitionDeletionTimestamp added in v0.19.0

func WithCustomResourceDefinitionDeletionTimestamp() CustomResourceDefinitionOption

func WithCustomResourceDefinitionGroup added in v0.14.0

func WithCustomResourceDefinitionGroup(group string) CustomResourceDefinitionOption

func WithCustomResourceDefinitionLabels added in v0.7.0

func WithCustomResourceDefinitionLabels(labels map[string]string) CustomResourceDefinitionOption

WithCustomResourceDefinitionLabels sets the CRD's labels.

func WithCustomResourceDefinitionNames added in v0.14.0

func WithCustomResourceDefinitionNames(names apiextensionsv1.CustomResourceDefinitionNames) CustomResourceDefinitionOption

func WithCustomResourceDefinitionVersions added in v0.14.0

func WithCustomResourceDefinitionVersions(versions []apiextensionsv1.CustomResourceDefinitionVersion) CustomResourceDefinitionOption

type DeploymentOption added in v0.6.0

type DeploymentOption func(*appsv1.Deployment)

DeploymentOption enables further configuration of a Deployment.

func WithDeploymentAnnotations added in v0.6.0

func WithDeploymentAnnotations(annotations map[string]string) DeploymentOption

func WithDeploymentAvailable added in v0.8.0

func WithDeploymentAvailable() DeploymentOption

WithDeploymentAvailable marks the Deployment as available.

func WithDeploymentContainer added in v0.6.0

func WithDeploymentContainer(name, image string, liveness *corev1.Probe, readiness *corev1.Probe, envVars []corev1.EnvVar, containerPorts []corev1.ContainerPort) DeploymentOption

func WithDeploymentLabels added in v0.6.0

func WithDeploymentLabels(labels map[string]string) DeploymentOption

func WithDeploymentOwnerReferences added in v0.6.0

func WithDeploymentOwnerReferences(ownerReferences []metav1.OwnerReference) DeploymentOption

func WithDeploymentServiceAccount added in v0.6.0

func WithDeploymentServiceAccount(serviceAccountName string) DeploymentOption

type DynamicMocks added in v0.5.0

type DynamicMocks struct {
	// MockResources corresponds to dynamic.Interface.
	MockResources []MockDynamicResource

	// All other fields correspond to their dynamic.ResourceInterface equivalents.
	MockCreates           []MockDynamicCreate
	MockUpdates           []MockDynamicUpdate
	MockUpdateStatuses    []MockDynamicUpdateStatus
	MockDeletes           []MockDynamicDelete
	MockDeleteCollections []MockDynamicDeleteCollection
	MockGets              []MockDynamicGet
	MockLists             []MockDynamicList
	MockWatches           []MockDynamicWatch
	MockPatches           []MockDynamicPatch
}

The mocks to run on each function type. Each function will run through the mocks in its list until one responds with 'Handled'. If there is more than one mock in the list, then the one that responds 'Handled' will be removed and not run on subsequent calls to the function. If no mocks respond 'Handled', then the real underlying client is called.

type EndpointsOption added in v0.14.0

type EndpointsOption func(*corev1.Endpoints)

EndpointsOption enables further configuration of a Endpoints.

func WithEndpointsAddresses added in v0.14.0

func WithEndpointsAddresses(addrs ...corev1.EndpointAddress) EndpointsOption

func WithEndpointsAnnotations added in v0.14.0

func WithEndpointsAnnotations(annotations map[string]string) EndpointsOption

func WithEndpointsLabels added in v0.14.0

func WithEndpointsLabels(labels map[string]string) EndpointsOption

func WithEndpointsNotReadyAddresses added in v0.14.0

func WithEndpointsNotReadyAddresses(addrs ...corev1.EndpointAddress) EndpointsOption

type EventTypeOption added in v0.6.0

type EventTypeOption func(*v1beta1.EventType)

EventTypeOption enables further configuration of an EventType.

func WithEventTypeBroker added in v0.6.0

func WithEventTypeBroker(broker string) EventTypeOption

func WithEventTypeBrokerFailed added in v0.12.0

func WithEventTypeBrokerFailed(reason, message string) EventTypeOption

func WithEventTypeBrokerUnknown added in v0.12.0

func WithEventTypeBrokerUnknown(reason, message string) EventTypeOption

func WithEventTypeDescription added in v0.6.0

func WithEventTypeDescription(description string) EventTypeOption

func WithEventTypeLabels added in v0.6.0

func WithEventTypeLabels(labels map[string]string) EventTypeOption

func WithEventTypeOwnerReference added in v0.6.0

func WithEventTypeOwnerReference(ownerRef metav1.OwnerReference) EventTypeOption

func WithEventTypeSource added in v0.6.0

func WithEventTypeSource(source *apis.URL) EventTypeOption

func WithEventTypeType added in v0.6.0

func WithEventTypeType(t string) EventTypeOption

type Listers added in v0.6.0

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

func NewListers added in v0.6.0

func NewListers(objs []runtime.Object) Listers

func (*Listers) GetAPIExtentionsObjects added in v0.17.0

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

func (*Listers) GetAllObjects added in v0.6.0

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

func (*Listers) GetConfigMapLister added in v0.6.0

func (l *Listers) GetConfigMapLister() corev1listers.ConfigMapLister

func (*Listers) GetCustomResourceDefinitionLister added in v0.7.0

func (l *Listers) GetCustomResourceDefinitionLister() apiextensionsv1listers.CustomResourceDefinitionLister

func (*Listers) GetDeploymentLister added in v0.6.0

func (l *Listers) GetDeploymentLister() appsv1listers.DeploymentLister

func (*Listers) GetEndpointsLister added in v0.6.0

func (l *Listers) GetEndpointsLister() corev1listers.EndpointsLister

func (*Listers) GetEventingObjects added in v0.6.0

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

func (*Listers) GetK8sServiceLister added in v0.6.0

func (l *Listers) GetK8sServiceLister() corev1listers.ServiceLister

func (*Listers) GetKubeObjects added in v0.6.0

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

func (*Listers) GetNamespaceLister added in v0.6.0

func (l *Listers) GetNamespaceLister() corev1listers.NamespaceLister

func (*Listers) GetPingSourceV1beta2Lister added in v0.20.0

func (l *Listers) GetPingSourceV1beta2Lister() sourcev1beta2listers.PingSourceLister

func (*Listers) GetRoleBindingLister added in v0.6.0

func (l *Listers) GetRoleBindingLister() rbacv1listers.RoleBindingLister

func (*Listers) GetSecretLister added in v0.18.0

func (l *Listers) GetSecretLister() corev1listers.SecretLister

func (*Listers) GetServiceAccountLister added in v0.6.0

func (l *Listers) GetServiceAccountLister() corev1listers.ServiceAccountLister

func (*Listers) GetServiceLister added in v0.7.0

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

func (*Listers) GetSubscriberObjects added in v0.6.0

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

type MockDynamicContext added in v0.5.0

type MockDynamicContext struct {
	InnerInterface dynamic.ResourceInterface
	Resource       schema.GroupVersionResource
	Namespace      string
}

type MockDynamicCreate added in v0.5.0

type MockDynamicCreate func(ctx *MockDynamicContext, obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (MockHandled, *unstructured.Unstructured, error)

All of the functions in dynamic.Resource get mocked equivalents. For the function dynamic.Resource.Foo(), the mocked equivalent will be: MockDynamicFoo func(ctx *MockDynamicContext[, Foo's arguments]) (MockHandled[, Foo's returns])

type MockDynamicDelete added in v0.5.0

type MockDynamicDelete func(ctx *MockDynamicContext, name string, options metav1.DeleteOptions, subresources ...string) (MockHandled, error)

type MockDynamicDeleteCollection added in v0.5.0

type MockDynamicDeleteCollection func(ctx *MockDynamicContext, options metav1.DeleteOptions, listOptions metav1.ListOptions) (MockHandled, error)

type MockDynamicGet added in v0.5.0

type MockDynamicGet func(ctx *MockDynamicContext, name string, options metav1.GetOptions, subresources ...string) (MockHandled, *unstructured.Unstructured, error)

type MockDynamicInterface added in v0.5.0

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

func NewMockDynamicInterface added in v0.5.0

func NewMockDynamicInterface(innerInterface dynamic.Interface, mocks DynamicMocks) *MockDynamicInterface

func (MockDynamicInterface) Resource added in v0.5.0

type MockDynamicList added in v0.5.0

type MockDynamicPatch added in v0.5.0

type MockDynamicPatch func(ctx *MockDynamicContext, name string, pt types.PatchType, data []byte, options metav1.PatchOptions, subresources ...string) (MockHandled, *unstructured.Unstructured, error)

type MockDynamicResource added in v0.5.0

type MockDynamicResource func(innerInterface dynamic.Interface, resource schema.GroupVersionResource) (MockHandled, dynamic.NamespaceableResourceInterface)

All of the functions in dynamic.Interface get mocked equivalents.

type MockDynamicUpdate added in v0.5.0

type MockDynamicUpdate func(ctx *MockDynamicContext, obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (MockHandled, *unstructured.Unstructured, error)

type MockDynamicUpdateStatus added in v0.5.0

type MockDynamicUpdateStatus func(ctx *MockDynamicContext, obj *unstructured.Unstructured, options metav1.UpdateOptions) (MockHandled, *unstructured.Unstructured, error)

type MockDynamicWatch added in v0.5.0

type MockDynamicWatch func(ctx *MockDynamicContext, opts metav1.ListOptions) (MockHandled, watch.Interface, error)

type MockEventRecorder

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

MockEventRecorder is a recorder.EventRecorder that saves emitted v1 Events.

func NewEventRecorder

func NewEventRecorder() *MockEventRecorder

func (*MockEventRecorder) AnnotatedEventf

func (m *MockEventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})

func (*MockEventRecorder) Event

func (m *MockEventRecorder) Event(object runtime.Object, eventtype, reason, message string)

func (*MockEventRecorder) Eventf

func (m *MockEventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

func (*MockEventRecorder) PastEventf

func (m *MockEventRecorder) PastEventf(object runtime.Object, timestamp metav1.Time, eventtype, reason, messageFmt string, args ...interface{})

type MockHandled

type MockHandled int
const (
	// This mock has handled the function call, no further mocks nor the real client should be
	// called.
	Handled MockHandled = iota
	// This mock has not handled the function call, subsequent mocks or the real client should be
	// called.
	Unhandled
)

type NamespaceOption added in v0.6.0

type NamespaceOption func(*corev1.Namespace)

NamespaceOption enables further configuration of a Namespace.

func WithNamespaceLabeled added in v0.6.0

func WithNamespaceLabeled(labels map[string]string) NamespaceOption

type ServiceOption added in v0.6.0

type ServiceOption func(*corev1.Service)

ServiceOption enables further configuration of a Service.

func WithServiceAnnotations added in v0.8.0

func WithServiceAnnotations(annotations map[string]string) ServiceOption

func WithServiceLabels added in v0.6.0

func WithServiceLabels(labels map[string]string) ServiceOption

func WithServiceOwnerReferences added in v0.6.0

func WithServiceOwnerReferences(ownerReferences []metav1.OwnerReference) ServiceOption

func WithServicePorts added in v0.6.0

func WithServicePorts(ports []corev1.ServicePort) ServiceOption

type UnstructuredOption added in v0.6.0

type UnstructuredOption func(*unstructured.Unstructured)

UnstructuredOption enables further configuration of a Unstructured.

func WithUnstructuredAddressable added in v0.6.0

func WithUnstructuredAddressable(hostname string) UnstructuredOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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