testing

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 45 Imported by: 0

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) Factory

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

func MarkSubscriptionReady added in v0.6.0

func MarkSubscriptionReady(s *v1alpha1.Subscription)

func NewApiServerSource added in v0.6.0

func NewApiServerSource(name, namespace string, o ...ApiServerSourceOption) *v1alpha1.ApiServerSource

NewApiServerSource creates a ApiServer with ApiServerOptions

func NewBroker added in v0.6.0

func NewBroker(name, namespace string, o ...BrokerOption) *v1alpha1.Broker

NewBroker creates a Broker with BrokerOptions.

func NewChannel added in v0.6.0

func NewChannel(name, namespace string, o ...ChannelOption) *v1alpha1.Channel

NewChannel creates a Channel with ChannelOptions

func NewChannelWithoutNamespace added in v0.6.0

func NewChannelWithoutNamespace(name string, o ...ChannelOption) *v1alpha1.Channel

NewChannelWithoutNamespace creates a Channel with ChannelOptions but without a specific namespace

func NewContainerSource added in v0.6.0

func NewContainerSource(name, namespace string, o ...ContainerSourceOption) *v1alpha1.ContainerSource

NewCronJob creates a CronJob with CronJobOptions

func NewCronSourceJob added in v0.6.0

func NewCronSourceJob(name, namespace string, o ...CronJobSourceOption) *v1alpha1.CronJobSource

NewCronJob creates a CronJob with CronJobOptions

func NewDeployment added in v0.6.0

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

NewDeployment creates a Deployment with DeploymentOptions.

func NewEventType added in v0.6.0

func NewEventType(name, namespace string, o ...EventTypeOption) *v1alpha1.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 NewSubscription added in v0.6.0

func NewSubscription(name, namespace string, so ...SubscriptionOption) *v1alpha1.Subscription

NewSubscription creates a Subscription with SubscriptionOptions

func NewSubscriptionWithoutNamespace added in v0.6.0

func NewSubscriptionWithoutNamespace(name string, so ...SubscriptionOption) *v1alpha1.Subscription

NewSubscriptionWithoutNamespace creates a Subscription with SubscriptionOptions but without a specific namespace

func NewTrigger added in v0.6.0

func NewTrigger(name, namespace, broker string, to ...TriggerOption) *v1alpha1.Trigger

NewTrigger creates a Trigger with TriggerOptions.

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 WithApiServerSourceDeleted added in v0.6.0

func WithApiServerSourceDeleted(c *v1alpha1.ApiServerSource)

func WithApiServerSourceDeployed added in v0.6.0

func WithApiServerSourceDeployed(s *v1alpha1.ApiServerSource)

func WithApiServerSourceEventTypes added in v0.6.0

func WithApiServerSourceEventTypes(s *v1alpha1.ApiServerSource)

func WithApiServerSourceSinkNotFound added in v0.6.0

func WithApiServerSourceSinkNotFound(s *v1alpha1.ApiServerSource)

func WithBrokerDeletionTimestamp added in v0.6.0

func WithBrokerDeletionTimestamp(b *v1alpha1.Broker)

func WithBrokerReady added in v0.6.0

func WithBrokerReady(b *v1alpha1.Broker)

WithBrokerReady sets .Status to ready.

func WithChannelDeleted added in v0.6.0

func WithChannelDeleted(c *v1alpha1.Channel)

func WithChannelReady added in v0.6.0

func WithChannelReady(c *v1alpha1.Channel)

func WithContainerSourceDeleted added in v0.6.0

func WithContainerSourceDeleted(c *v1alpha1.ContainerSource)

func WithContainerSourceDeployed added in v0.6.0

func WithContainerSourceDeployed(s *v1alpha1.ContainerSource)

func WithCronJobSourceDeleted added in v0.6.0

func WithCronJobSourceDeleted(c *v1alpha1.CronJobSource)

func WithCronJobSourceDeployed added in v0.6.0

func WithCronJobSourceDeployed(s *v1alpha1.CronJobSource)

func WithCronJobSourceEventType added in v0.6.0

func WithCronJobSourceEventType(s *v1alpha1.CronJobSource)

func WithCronJobSourceSinkNotFound added in v0.6.0

func WithCronJobSourceSinkNotFound(s *v1alpha1.CronJobSource)

func WithEventTypeBrokerDoesNotExist added in v0.6.0

func WithEventTypeBrokerDoesNotExist(et *v1alpha1.EventType)

WithEventTypeBrokerNotFound calls .Status.MarkFilterFailed on the EventType.

func WithEventTypeBrokerExists added in v0.6.0

func WithEventTypeBrokerExists(et *v1alpha1.EventType)

WithEventTypeBrokerExists calls .Status.MarkBrokerExists on the EventType.

func WithEventTypeBrokerNotReady added in v0.6.0

func WithEventTypeBrokerNotReady(et *v1alpha1.EventType)

WithEventTypeBrokerNotReady calls .Status.MarkBrokerNotReady on the EventType.

func WithEventTypeBrokerReady added in v0.6.0

func WithEventTypeBrokerReady(et *v1alpha1.EventType)

WithEventTypeBrokerReady calls .Status.MarkBrokerReady on the EventType.

func WithEventTypeDeletionTimestamp added in v0.6.0

func WithEventTypeDeletionTimestamp(et *v1alpha1.EventType)

func WithInitApiServerSourceConditions added in v0.6.0

func WithInitApiServerSourceConditions(s *v1alpha1.ApiServerSource)

WithInitApiServerConditions initializes the ApiServerSource's conditions.

func WithInitBrokerConditions added in v0.6.0

func WithInitBrokerConditions(b *v1alpha1.Broker)

WithInitBrokerConditions initializes the Broker's conditions.

func WithInitChannelConditions added in v0.6.0

func WithInitChannelConditions(s *v1alpha1.Channel)

WithInitChannelConditions initializes the Channel's conditions.

func WithInitContainerSourceConditions added in v0.6.0

func WithInitContainerSourceConditions(s *v1alpha1.ContainerSource)

WithInitContainerSourceConditions initializes the ContainerSource's conditions.

func WithInitCronJobSourceConditions added in v0.6.0

func WithInitCronJobSourceConditions(s *v1alpha1.CronJobSource)

WithInitCronJobConditions initializes the CronJobSource's conditions.

func WithInitEventTypeConditions added in v0.6.0

func WithInitEventTypeConditions(et *v1alpha1.EventType)

WithInitEventTypeConditions initializes the EventType's conditions.

func WithInitSubscriptionConditions added in v0.6.0

func WithInitSubscriptionConditions(s *v1alpha1.Subscription)

WithInitSubscriptionConditions initializes the Subscriptions's conditions.

func WithInitTriggerConditions added in v0.6.0

func WithInitTriggerConditions(t *v1alpha1.Trigger)

WithInitTriggerConditions initializes the Triggers's conditions.

func WithInvalidCronJobSourceSchedule added in v0.6.0

func WithInvalidCronJobSourceSchedule(s *v1alpha1.CronJobSource)

func WithNamespaceDeleted added in v0.6.0

func WithNamespaceDeleted(n *corev1.Namespace)

func WithSubscriptionDeleted added in v0.6.0

func WithSubscriptionDeleted(s *v1alpha1.Subscription)

TODO: this can be a runtime object

func WithSubscriptionReady added in v0.6.0

func WithSubscriptionReady(s *v1alpha1.Subscription)

func WithTriggerDeleted added in v0.6.0

func WithTriggerDeleted(t *v1alpha1.Trigger)

TODO: this can be a runtime object

func WithValidCronJobSourceSchedule added in v0.6.0

func WithValidCronJobSourceSchedule(s *v1alpha1.CronJobSource)

Types

type ApiServerSourceOption added in v0.6.0

type ApiServerSourceOption func(*v1alpha1.ApiServerSource)

ApiServerSourceOption enables further configuration of a ApiServer.

func WithApiServerSourceSink added in v0.6.0

func WithApiServerSourceSink(uri string) ApiServerSourceOption

func WithApiServerSourceSpec added in v0.6.0

func WithApiServerSourceSpec(spec v1alpha1.ApiServerSourceSpec) ApiServerSourceOption

type BrokerOption added in v0.6.0

type BrokerOption func(*v1alpha1.Broker)

BrokerOption enables further configuration of a Broker.

func WithBrokerAddress added in v0.6.0

func WithBrokerAddress(address string) BrokerOption

WithBrokerAddress sets the Broker's address.

func WithBrokerChannelProvisioner added in v0.6.0

func WithBrokerChannelProvisioner(provisioner *corev1.ObjectReference) BrokerOption

WithBrokerChannelProvisioner sets the Broker's ChannelTemplate provisioner.

func WithBrokerIngressChannelReady added in v0.6.0

func WithBrokerIngressChannelReady() BrokerOption

func WithBrokerIngressSubscriptionFailed added in v0.6.0

func WithBrokerIngressSubscriptionFailed(reason, msg string) BrokerOption

func WithFilterDeploymentAvailable added in v0.6.0

func WithFilterDeploymentAvailable() BrokerOption

func WithFilterFailed added in v0.6.0

func WithFilterFailed(reason, msg string) BrokerOption

WithFilterFailed calls .Status.MarkFilterFailed on the Broker.

func WithIngressChannelFailed added in v0.6.0

func WithIngressChannelFailed(reason, msg string) BrokerOption

WithIngressChannelFailed calls .Status.MarkIngressChannelFailed on the Broker.

func WithIngressDeploymentAvailable added in v0.6.0

func WithIngressDeploymentAvailable() BrokerOption

func WithIngressFailed added in v0.6.0

func WithIngressFailed(reason, msg string) BrokerOption

WithIngressFailed calls .Status.MarkIngressFailed on the Broker.

func WithTriggerChannelFailed added in v0.6.0

func WithTriggerChannelFailed(reason, msg string) BrokerOption

WithTriggerChannelFailed calls .Status.MarkTriggerChannelFailed on the Broker.

func WithTriggerChannelReady added in v0.6.0

func WithTriggerChannelReady() BrokerOption

WithTriggerChannelReady calls .Status.PropagateTriggerChannelReadiness on the Broker.

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 ChannelOption added in v0.6.0

type ChannelOption func(*v1alpha1.Channel)

ChannelOption enables further configuration of a Channel.

func WithChannelAddress added in v0.6.0

func WithChannelAddress(hostname string) ChannelOption

func WithChannelGenerateName added in v0.6.0

func WithChannelGenerateName(generateName string) ChannelOption

func WithChannelLabels added in v0.6.0

func WithChannelLabels(labels map[string]string) ChannelOption

func WithChannelOwnerReferences added in v0.6.0

func WithChannelOwnerReferences(ownerReferences []metav1.OwnerReference) ChannelOption

func WithChannelProvisioner added in v0.6.0

func WithChannelProvisioner(gvk metav1.GroupVersionKind, name string) ChannelOption

func WithChannelProvisionerNotFound added in v0.6.0

func WithChannelProvisionerNotFound(name, kind string) ChannelOption

func WithChannelSubscribers added in v0.6.0

func WithChannelSubscribers(subscribers []duckv1alpha1.ChannelSubscriberSpec) ChannelOption

type ContainerSourceOption added in v0.6.0

type ContainerSourceOption func(*v1alpha1.ContainerSource)

ContainerSourceOption enables further configuration of a CronJob.

func WithContainerSourceAnnotations added in v0.6.0

func WithContainerSourceAnnotations(annotations map[string]string) ContainerSourceOption

func WithContainerSourceDeployFailed added in v0.6.0

func WithContainerSourceDeployFailed(msg string) ContainerSourceOption

func WithContainerSourceDeploying added in v0.6.0

func WithContainerSourceDeploying(msg string) ContainerSourceOption

func WithContainerSourceLabels added in v0.6.0

func WithContainerSourceLabels(labels map[string]string) ContainerSourceOption

func WithContainerSourceSink added in v0.6.0

func WithContainerSourceSink(uri string) ContainerSourceOption

func WithContainerSourceSinkMissing added in v0.6.0

func WithContainerSourceSinkMissing(msg string) ContainerSourceOption

func WithContainerSourceSinkNotFound added in v0.6.0

func WithContainerSourceSinkNotFound(msg string) ContainerSourceOption

func WithContainerSourceSpec added in v0.6.0

func WithContainerSourceSpec(spec v1alpha1.ContainerSourceSpec) ContainerSourceOption

func WithContainerSourceUID added in v0.6.0

func WithContainerSourceUID(uid types.UID) ContainerSourceOption

type CronJobSourceOption added in v0.6.0

type CronJobSourceOption func(*v1alpha1.CronJobSource)

CronJobSourceOption enables further configuration of a CronJob.

func WithCronJobSourceSink added in v0.6.0

func WithCronJobSourceSink(uri string) CronJobSourceOption

func WithCronJobSourceSpec added in v0.6.0

func WithCronJobSourceSpec(spec v1alpha1.CronJobSourceSpec) CronJobSourceOption

type Ctor added in v0.6.0

Ctor functions create a k8s controller with given params.

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 WithDeploymentContainer added in v0.6.0

func WithDeploymentContainer(name, image string, 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 EventTypeOption added in v0.6.0

type EventTypeOption func(*v1alpha1.EventType)

EventTypeOption enables further configuration of an EventType.

func WithEventTypeBroker added in v0.6.0

func WithEventTypeBroker(broker string) EventTypeOption

func WithEventTypeDescription added in v0.6.0

func WithEventTypeDescription(description string) EventTypeOption

func WithEventTypeGenerateName added in v0.6.0

func WithEventTypeGenerateName(generateName 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 string) 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) GetAllObjects added in v0.6.0

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

func (*Listers) GetApiServerSourceLister added in v0.6.0

func (l *Listers) GetApiServerSourceLister() sourcelisters.ApiServerSourceLister

func (*Listers) GetBrokerLister added in v0.6.0

func (l *Listers) GetBrokerLister() eventinglisters.BrokerLister

func (*Listers) GetChannelLister added in v0.6.0

func (l *Listers) GetChannelLister() eventinglisters.ChannelLister

func (*Listers) GetConfigMapLister added in v0.6.0

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

func (*Listers) GetContainerSourceLister added in v0.6.0

func (l *Listers) GetContainerSourceLister() sourcelisters.ContainerSourceLister

func (*Listers) GetCronJobSourceLister added in v0.6.0

func (l *Listers) GetCronJobSourceLister() sourcelisters.CronJobSourceLister

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) GetEventTypeLister added in v0.6.0

func (l *Listers) GetEventTypeLister() eventinglisters.EventTypeLister

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) GetRoleBindingLister added in v0.6.0

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

func (*Listers) GetServiceAccountLister added in v0.6.0

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

func (*Listers) GetSharedObjects added in v0.6.0

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

func (*Listers) GetSubscriberObjects added in v0.6.0

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

func (*Listers) GetSubscriptionLister added in v0.6.0

func (l *Listers) GetSubscriptionLister() eventinglisters.SubscriptionLister

func (*Listers) GetTriggerLister added in v0.6.0

func (l *Listers) GetTriggerLister() eventinglisters.TriggerLister

type MockClient

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

mockClient is a client.Client that allows mock responses to be returned, instead of calling the inner client.Client.

func NewMockClient

func NewMockClient(innerClient client.Client, mocks Mocks) *MockClient

func (*MockClient) Create

func (m *MockClient) Create(ctx context.Context, obj runtime.Object) error

func (*MockClient) Delete

func (m *MockClient) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOptionFunc) error

func (*MockClient) Get

func (m *MockClient) Get(ctx context.Context, key client.ObjectKey, obj runtime.Object) error

func (*MockClient) List

func (m *MockClient) List(ctx context.Context, opts *client.ListOptions, list runtime.Object) error

func (*MockClient) Status

func (m *MockClient) Status() client.StatusWriter

func (*MockClient) Update

func (m *MockClient) Update(ctx context.Context, obj runtime.Object) error

type MockCreate

type MockCreate func(innerClient client.Client, ctx context.Context, obj runtime.Object) (MockHandled, error)

type MockDelete

type MockDelete func(innerClient client.Client, ctx context.Context, obj runtime.Object) (MockHandled, error)

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.UpdateOptions, 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 MockGet

type MockGet func(innerClient client.Client, ctx context.Context, key client.ObjectKey, obj runtime.Object) (MockHandled, error)

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 MockList

type MockList func(innerClient client.Client, ctx context.Context, opts *client.ListOptions, list runtime.Object) (MockHandled, error)

type MockStatusUpdate

type MockStatusUpdate func(innerClient client.Client, ctx context.Context, obj runtime.Object) (MockHandled, error)

type MockUpdate

type MockUpdate func(innerClient client.Client, ctx context.Context, obj runtime.Object) (MockHandled, error)

type Mocks

type Mocks struct {
	MockGets          []MockGet
	MockLists         []MockList
	MockCreates       []MockCreate
	MockDeletes       []MockDelete
	MockUpdates       []MockUpdate
	MockStatusUpdates []MockStatusUpdate
}

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 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 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 SubscriptionOption added in v0.6.0

type SubscriptionOption func(*v1alpha1.Subscription)

SubscriptionOption enables further configuration of a Subscription.

func WithSubscriptionChannel added in v0.6.0

func WithSubscriptionChannel(gvk metav1.GroupVersionKind, name string) SubscriptionOption

func WithSubscriptionFinalizers added in v0.6.0

func WithSubscriptionFinalizers(finalizers ...string) SubscriptionOption

func WithSubscriptionGenerateName added in v0.6.0

func WithSubscriptionGenerateName(generateName string) SubscriptionOption

func WithSubscriptionLabels added in v0.6.0

func WithSubscriptionLabels(labels map[string]string) SubscriptionOption

func WithSubscriptionOwnerReferences added in v0.6.0

func WithSubscriptionOwnerReferences(ownerReferences []metav1.OwnerReference) SubscriptionOption

func WithSubscriptionPhysicalSubscriptionReply added in v0.6.0

func WithSubscriptionPhysicalSubscriptionReply(uri string) SubscriptionOption

func WithSubscriptionPhysicalSubscriptionSubscriber added in v0.6.0

func WithSubscriptionPhysicalSubscriptionSubscriber(uri string) SubscriptionOption

func WithSubscriptionReply added in v0.6.0

func WithSubscriptionReply(gvk metav1.GroupVersionKind, name string) SubscriptionOption

func WithSubscriptionSubscriberRef added in v0.6.0

func WithSubscriptionSubscriberRef(gvk metav1.GroupVersionKind, name string) SubscriptionOption

func WithSubscriptionUID added in v0.6.0

func WithSubscriptionUID(uid types.UID) SubscriptionOption

type TestCase

type TestCase struct {
	// Name is a descriptive name for this test suitable as a first argument to t.Run()
	Name string

	// InitialState is the list of objects that already exists when reconciliation
	// starts.
	InitialState []runtime.Object

	// ReconcileKey is the key of the object to reconcile in namespace/name form.
	ReconcileKey string

	// WantErr is true when we expect the Reconcile function to return an error.
	WantErr bool

	// WantErrMsg contains the pattern to match the returned error message.
	// Implies WantErr = true.
	WantErrMsg string

	// WantResult is the reconcile result we expect to be returned from the
	// Reconcile function.
	WantResult reconcile.Result

	// WantPresent holds the non-exclusive set of objects we expect to exist
	// after reconciliation completes.
	WantPresent []runtime.Object

	// WantAbsent holds the list of objects expected to not exist
	// after reconciliation completes.
	WantAbsent []runtime.Object

	// WantEvent holds the list of events expected to exist after
	// reconciliation completes.
	WantEvent []corev1.Event

	// Mocks that tamper with the client's responses.
	Mocks Mocks

	// DynamicMocks that tamper with the dynamic client's responses.
	DynamicMocks DynamicMocks

	// Scheme for the dynamic client
	Scheme *runtime.Scheme

	// Fake dynamic objects
	Objects []runtime.Object

	// OtherTestData is arbitrary data needed for the test. It is not used directly by the table
	// testing framework. Instead it is used in the test method. E.g. setting up the responses for a
	// fake GCP PubSub client can go in here, as no other field makes sense for it.
	OtherTestData map[string]interface{}

	// AdditionalVerification is for any verification that needs to be done on top of the normal
	// result/error verification and WantPresent/WantAbsent.
	AdditionalVerification []func(t *testing.T, tc *TestCase)

	// IgnoreTimes causes comparisons to ignore fields of type apis.VolatileTime.
	IgnoreTimes bool
}

TestCase holds a single row of our table test.

func (*TestCase) GetClient

func (tc *TestCase) GetClient() *MockClient

GetClient returns the mockClient to use for this test case.

func (*TestCase) GetDynamicClient

func (tc *TestCase) GetDynamicClient() dynamic.Interface

GetDynamicClient returns the mockDynamicClient to use for this test case.

func (*TestCase) GetEventRecorder

func (tc *TestCase) GetEventRecorder() *MockEventRecorder

GetEventRecorder returns the mockEventRecorder to use for this test case.

func (*TestCase) Reconcile

func (tc *TestCase) Reconcile(r reconcile.Reconciler) (reconcile.Result, error)

Reconcile calls the given reconciler's Reconcile() function with the test case's reconcile request.

func (*TestCase) Runner

func (tc *TestCase) Runner(t *testing.T, r reconcile.Reconciler, c *MockClient, recorder *MockEventRecorder) func(t *testing.T)

Runner returns a testing func that can be passed to t.Run.

func (*TestCase) VerifyErr

func (tc *TestCase) VerifyErr(err error) error

VerifyErr verifies that the given error returned from Reconcile is the error expected by the test case.

func (*TestCase) VerifyResult

func (tc *TestCase) VerifyResult(result reconcile.Result) error

VerifyResult verifies that the given result returned from Reconcile is the result expected by the test case.

func (*TestCase) VerifyWantAbsent

func (tc *TestCase) VerifyWantAbsent(c client.Client) error

VerifyWantAbsent verifies that the client does not contain any of the objects expected to be absent after reconciliation.

func (*TestCase) VerifyWantEvent

func (tc *TestCase) VerifyWantEvent(eventRecorder *MockEventRecorder) error

VerifyWantEvent verifies that the eventRecorder does contain the events expected in the same order as they were emitted after reconciliation.

func (*TestCase) VerifyWantPresent

func (tc *TestCase) VerifyWantPresent(c client.Client) error

VerifyWantPresent verifies that the client contains all the objects expected to be present after reconciliation.

type TriggerOption added in v0.6.0

type TriggerOption func(*v1alpha1.Trigger)

TriggerOption enables further configuration of a Trigger.

func WithTriggerBrokerFailed added in v0.6.0

func WithTriggerBrokerFailed(reason, message string) TriggerOption

WithTriggerBrokerFailed marks the Broker as failed

func WithTriggerBrokerReady added in v0.6.0

func WithTriggerBrokerReady() TriggerOption

WithTriggerBrokerReady initializes the Triggers's conditions.

func WithTriggerNotSubscribed added in v0.6.0

func WithTriggerNotSubscribed(reason, message string) TriggerOption

func WithTriggerStatusSubscriberURI added in v0.6.0

func WithTriggerStatusSubscriberURI(uri string) TriggerOption

func WithTriggerSubscribed added in v0.6.0

func WithTriggerSubscribed() TriggerOption

func WithTriggerSubscriberRef added in v0.6.0

func WithTriggerSubscriberRef(gvk metav1.GroupVersionKind, name string) TriggerOption

func WithTriggerSubscriberURI added in v0.6.0

func WithTriggerSubscriberURI(uri string) TriggerOption

func WithTriggerUID added in v0.6.0

func WithTriggerUID(uid string) TriggerOption

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

Jump to

Keyboard shortcuts

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