testing

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 53 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 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 NewRoleBinding added in v1.3.0

func NewRoleBinding(sa *corev1.ServiceAccount) func() *rbacv1.RoleBinding

func NewScheme

func NewScheme() *runtime.Scheme

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

func NewServiceAccount added in v1.3.0

func NewServiceAccount(src kmeta.OwnerRefable) serviceAccountCtorWithOptions

func NewTestDeploymentReconciler added in v1.3.0

func NewTestDeploymentReconciler(ctx context.Context, ls *Listers) common.GenericDeploymentReconciler

NewTestDeploymentReconciler returns a GenericServiceReconciler initialized with test clients.

func NewTestServiceReconciler added in v1.3.0

func NewTestServiceReconciler(ctx context.Context, ls *Listers) common.GenericServiceReconciler

NewTestServiceReconciler returns a GenericServiceReconciler initialized with test clients.

func Populate

func Populate(srcCpy v1alpha1.EventSource)

Populate populates an event source with generic attributes.

func SetEnvVar

func SetEnvVar(t *testing.T, name, val string) (unset func())

SetEnvVar sets the value of an env var and returns a function that can be deferred to unset that variable.

func TestControllerConstructor

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

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 TestReconcileAdapter added in v1.3.0

func TestReconcileAdapter(t *testing.T, ctor Ctor, src v1alpha1.EventSource, adapterBuilder interface{})

Test the Reconcile() method of the controller.Reconciler implemented by source Reconcilers, with focus on the generic ReconcileSource logic executed by the generic adapter reconciler embedded in every source Reconciler.

The environment for each test case is set up as follows:

  1. MakeFactory initializes fake clients with the objects declared in the test case
  2. MakeFactory injects those clients into a context along with fake event recorders, etc.
  3. A Reconciler is constructed via a Ctor function using the values injected above
  4. The Reconciler returned by MakeFactory is used to run the test case

func ToUnstructured

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 Ctor

Ctor constructs a controller.Reconciler.

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

func (l *Listers) GetAzureActivityLogsSourceLister() listersv1alpha1.AzureActivityLogsSourceLister

GetAzureActivityLogsSourceLister returns a Lister for AzureActivityLogsSource objects.

func (*Listers) GetAzureBlobStorageSourceLister added in v0.6.0

func (l *Listers) GetAzureBlobStorageSourceLister() listersv1alpha1.AzureBlobStorageSourceLister

GetAzureBlobStorageSourceLister returns a Lister for AzureBlobStorageSource objects.

func (*Listers) GetAzureEventGridSourceLister added in v1.10.0

func (l *Listers) GetAzureEventGridSourceLister() listersv1alpha1.AzureEventGridSourceLister

GetAzureEventGridSourceLister returns a Lister for AzureEventGridSource objects.

func (*Listers) GetAzureEventHubSourceLister

func (l *Listers) GetAzureEventHubSourceLister() listersv1alpha1.AzureEventHubSourceLister

GetAzureEventHubSourceLister returns a Lister for AzureEventHubSource objects.

func (*Listers) GetAzureServiceBusQueueSourceLister added in v1.10.0

func (l *Listers) GetAzureServiceBusQueueSourceLister() listersv1alpha1.AzureServiceBusQueueSourceLister

GetAzureServiceBusQueueSourceLister returns a Lister for AzureServiceBusQueueSource objects.

func (*Listers) GetDeploymentLister

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

GetDeploymentLister returns a lister for Deployment objects.

func (*Listers) GetGoogleCloudAuditLogsSourceLister added in v1.10.0

func (l *Listers) GetGoogleCloudAuditLogsSourceLister() listersv1alpha1.GoogleCloudAuditLogsSourceLister

GetGoogleCloudAuditLogsSourceLister returns a Lister for GoogleCloudAuditLogsSource objects.

func (*Listers) GetGoogleCloudBillingSourceLister added in v1.10.0

func (l *Listers) GetGoogleCloudBillingSourceLister() listersv1alpha1.GoogleCloudBillingSourceLister

GetGoogleCloudBillingSourceLister returns a Lister for GoogleCloudBillingSource objects.

func (*Listers) GetGoogleCloudPubSubSourceLister added in v1.5.0

func (l *Listers) GetGoogleCloudPubSubSourceLister() listersv1alpha1.GoogleCloudPubSubSourceLister

GetGoogleCloudPubSubSourceLister returns a Lister for GoogleCloudPubSubSource objects.

func (*Listers) GetGoogleCloudRepositoriesSourceLister added in v1.10.0

func (l *Listers) GetGoogleCloudRepositoriesSourceLister() listersv1alpha1.GoogleCloudRepositoriesSourceLister

GetGoogleCloudRepositoriesSourceLister returns a Lister for GoogleCloudRepositoriesSource objects.

func (*Listers) GetGoogleCloudStorageSourceLister added in v1.4.1

func (l *Listers) GetGoogleCloudStorageSourceLister() listersv1alpha1.GoogleCloudStorageSourceLister

GetGoogleCloudStorageSourceLister returns a Lister for GoogleCloudStorageSource objects.

func (*Listers) GetKubeObjects

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

GetKubeObjects returns objects from Kubernetes APIs.

func (*Listers) GetOCIMetricsSourceLister added in v0.7.0

func (l *Listers) GetOCIMetricsSourceLister() listersv1alpha1.OCIMetricsSourceLister

GetOCIMetricsSourceLister returns a Lister for OCIMetricsSource objects.

func (*Listers) GetRoleBindingLister added in v1.3.0

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

GetRoleBindingLister returns a lister for RoleBinding objects

func (*Listers) GetSalesforceSourceLister added in v0.6.0

func (l *Listers) GetSalesforceSourceLister() listersv1alpha1.SalesforceSourceLister

GetSalesforceSourceLister returns a Lister for SalesforceSource objects.

func (*Listers) GetServiceAccountLister added in v1.3.0

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

GetServiceAccountLister returns a lister for ServiceAccount objects.

func (*Listers) GetServiceLister

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

GetServiceLister returns a lister for Knative Service objects.

func (*Listers) GetServingObjects

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

GetServingObjects returns objects from the serving API.

func (*Listers) GetSourcesObjects

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

GetSourcesObjects returns objects from the sources API.

func (*Listers) GetTwilioSourceLister added in v1.2.0

func (l *Listers) GetTwilioSourceLister() listersv1alpha1.TwilioSourceLister

GetTwilioSourceLister returns a Lister for TwilioSource objects.

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