Documentation ¶
Overview ¶
Package testing contains test helpers for reconcilers.
Index ¶
- func EnsureNoNilField(t *testing.T, impl *controller.Impl)
- func MakeFactory(ctor Ctor) rt.Factory
- func NewARN(service, resource string) arn.ARN
- func NewConfigMap(name string, data map[string]string) *corev1.ConfigMap
- func NewScheme() *runtime.Scheme
- func Populate(srcCpy v1alpha1.AWSEventSource)
- func SetEnvVar(t *testing.T, name, val string) (unset func())
- func TestControllerConstructor(t *testing.T, ctor injection.ControllerConstructor)
- func TestControllerConstructorFailures(t *testing.T, ctor injection.ControllerConstructor)
- func TestReconcile(t *testing.T, ctor Ctor, src v1alpha1.AWSEventSource, adapterFn interface{})
- func ToUnstructured(t *testing.T, objs []runtime.Object) (unstr []runtime.Object)
- type Ctor
- type FakeOwnerRefable
- type Listers
- func (l *Listers) GetAWSCodeCommitSourceLister() listersv1alpha1.AWSCodeCommitSourceLister
- func (l *Listers) GetAWSCognitoIdentitySourceLister() listersv1alpha1.AWSCognitoIdentitySourceLister
- func (l *Listers) GetAWSCognitoUserPoolSourceLister() listersv1alpha1.AWSCognitoUserPoolSourceLister
- func (l *Listers) GetAWSDynamoDBSourceLister() listersv1alpha1.AWSDynamoDBSourceLister
- func (l *Listers) GetAWSIoTSourceLister() listersv1alpha1.AWSIoTSourceLister
- func (l *Listers) GetAWSKinesisSourceLister() listersv1alpha1.AWSKinesisSourceLister
- func (l *Listers) GetAWSSNSSourceLister() listersv1alpha1.AWSSNSSourceLister
- func (l *Listers) GetAWSSQSSourceLister() listersv1alpha1.AWSSQSSourceLister
- func (l *Listers) GetDeploymentLister() k8slistersv1.DeploymentLister
- func (l *Listers) GetKubeObjects() []runtime.Object
- func (l *Listers) GetServiceLister() servinglistersv1.ServiceLister
- func (l *Listers) GetServingObjects() []runtime.Object
- func (l *Listers) GetSourcesObjects() []runtime.Object
- func (l *Listers) IndexerFor(obj runtime.Object) cache.Indexer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureNoNilField ¶
func EnsureNoNilField(t *testing.T, impl *controller.Impl)
EnsureNoNilField fails the test if the provided Impl's reconciler contains nil pointers or interfaces.
func MakeFactory ¶
MakeFactory creates a testing factory for our controller.Reconciler, and initializes a Reconciler using the given Ctor as part of the process.
func NewConfigMap ¶
NewConfigMap returns a ConfigMap object.
func NewScheme ¶
NewScheme returns a new scheme populated with the types defined in clientSetSchemes.
func Populate ¶
func Populate(srcCpy v1alpha1.AWSEventSource)
Populate populates an event source with generic attributes.
func SetEnvVar ¶
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 TestReconcile ¶
func TestReconcile(t *testing.T, ctor Ctor, src v1alpha1.AWSEventSource, adapterFn interface{})
Test the Reconcile method of the controller.Reconciler implemented by controllers.
The environment for each test case is set up as follows:
- MakeFactory initializes fake clients with the objects declared in the test case
- MakeFactory injects those clients into a context along with fake event recorders, etc.
- A Reconciler is constructed via a Ctor function using the values injected above
- The Reconciler returned by MakeFactory is used to run the test case
Types ¶
type Ctor ¶
type Ctor func(*testing.T, context.Context, *Listers) controller.Reconciler
Ctor constructs a controller.Reconciler.
type FakeOwnerRefable ¶
type FakeOwnerRefable struct { metav1.ObjectMeta schema.GroupVersionKind }
FakeOwnerRefable implements OwnerRefable.
func DummyOwnerRefable ¶
func DummyOwnerRefable() *FakeOwnerRefable
DummyOwnerRefable returns a OwnerRefable with dummy attributes.
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 ¶
NewListers returns a new instance of Listers initialized with the given objects.
func (*Listers) GetAWSCodeCommitSourceLister ¶
func (l *Listers) GetAWSCodeCommitSourceLister() listersv1alpha1.AWSCodeCommitSourceLister
GetAWSCodeCommitSourceLister returns a Lister for AWSCodeCommitSource objects.
func (*Listers) GetAWSCognitoIdentitySourceLister ¶
func (l *Listers) GetAWSCognitoIdentitySourceLister() listersv1alpha1.AWSCognitoIdentitySourceLister
GetAWSCognitoIdentitySourceLister returns a Lister for AWSCognitoUserPoolSource objects.
func (*Listers) GetAWSCognitoUserPoolSourceLister ¶
func (l *Listers) GetAWSCognitoUserPoolSourceLister() listersv1alpha1.AWSCognitoUserPoolSourceLister
GetAWSCognitoUserPoolSourceLister returns a Lister for AWSCognitoIdentitySource objects.
func (*Listers) GetAWSDynamoDBSourceLister ¶
func (l *Listers) GetAWSDynamoDBSourceLister() listersv1alpha1.AWSDynamoDBSourceLister
GetAWSDynamoDBSourceLister returns a Lister for AWSDynamoDBSource objects.
func (*Listers) GetAWSIoTSourceLister ¶
func (l *Listers) GetAWSIoTSourceLister() listersv1alpha1.AWSIoTSourceLister
GetAWSIoTSourceLister returns a Lister for AWSIoTSource objects.
func (*Listers) GetAWSKinesisSourceLister ¶
func (l *Listers) GetAWSKinesisSourceLister() listersv1alpha1.AWSKinesisSourceLister
GetAWSKinesisSourceLister returns a Lister for AWSKinesisSource objects.
func (*Listers) GetAWSSNSSourceLister ¶
func (l *Listers) GetAWSSNSSourceLister() listersv1alpha1.AWSSNSSourceLister
GetAWSSNSSourceLister returns a Lister for AWSSNSSource objects.
func (*Listers) GetAWSSQSSourceLister ¶
func (l *Listers) GetAWSSQSSourceLister() listersv1alpha1.AWSSQSSourceLister
GetAWSSQSSourceLister returns a Lister for AWSSQSSource objects.
func (*Listers) GetDeploymentLister ¶
func (l *Listers) GetDeploymentLister() k8slistersv1.DeploymentLister
GetDeploymentLister returns a lister for Deployment objects.
func (*Listers) GetKubeObjects ¶
GetKubeObjects returns objects from Kubernetes APIs.
func (*Listers) GetServiceLister ¶
func (l *Listers) GetServiceLister() servinglistersv1.ServiceLister
GetServiceLister returns a lister for Service objects.
func (*Listers) GetServingObjects ¶
GetServingObjects returns objects from the serving API.
func (*Listers) GetSourcesObjects ¶
GetSourcesObjects returns objects from the sources API.