Documentation
¶
Overview ¶
Package testing contains test helpers for reconcilers.
Index ¶
- func MakeFactory(ctor Ctor) rt.Factory
- func NewConfigMap(name string, data map[string]string) *corev1.ConfigMap
- func NewRoleBinding(sa *corev1.ServiceAccount) func() *rbacv1.RoleBinding
- func NewScheme() *runtime.Scheme
- func NewTestServiceReconciler(ctx context.Context, ls *Listers) common.GenericServiceReconciler
- func NoToken(sa *corev1.ServiceAccount)
- func Populate(rclCpy v1alpha1.Reconcilable)
- func TestControllerConstructor(t *testing.T, ctor injection.ControllerConstructor)
- func TestControllerConstructorFailures(t *testing.T, ctor injection.ControllerConstructor)
- func TestReconcileAdapter(t *testing.T, ctor Ctor, rcl v1alpha1.Reconcilable, adapterBuilder interface{})
- func ToUnstructured(t *testing.T, objs []runtime.Object) (unstr []runtime.Object)
- type Ctor
- type Listers
- func (l *Listers) GetDataWeaveTransformationLister() flowlisters.DataWeaveTransformationLister
- func (l *Listers) GetFlowObjects() []runtime.Object
- func (l *Listers) GetJQTransformationLister() flowlisters.JQTransformationLister
- func (l *Listers) GetKubeObjects() []runtime.Object
- func (l *Listers) GetRoleBindingLister() rbaclistersv1.RoleBindingLister
- func (l *Listers) GetServiceAccountLister() corelistersv1.ServiceAccountLister
- func (l *Listers) GetServiceLister() servinglistersv1.ServiceLister
- func (l *Listers) GetServingObjects() []runtime.Object
- func (l *Listers) GetSynchronizerLister() flowlisters.SynchronizerLister
- func (l *Listers) GetTransformationLister() flowlisters.TransformationLister
- func (l *Listers) GetXMLToJSONTransformationLister() flowlisters.XMLToJSONTransformationLister
- func (l *Listers) GetXSLTTransformationLister() flowlisters.XSLTTransformationLister
- func (l *Listers) IndexerFor(obj runtime.Object) cache.Indexer
- type ServiceAccountCtorWithOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 NewRoleBinding ¶ added in v1.16.0
func NewRoleBinding(sa *corev1.ServiceAccount) func() *rbacv1.RoleBinding
NewRoleBinding returns a RoleBinding constructor for the given ServiceAccount.
func NewScheme ¶
NewScheme returns a new scheme populated with the types defined in clientSetSchemes.
func NewTestServiceReconciler ¶ added in v1.16.0
func NewTestServiceReconciler(ctx context.Context, ls *Listers) common.GenericServiceReconciler
NewTestServiceReconciler returns a GenericServiceReconciler initialized with test clients.
func NoToken ¶ added in v1.16.0
func NoToken(sa *corev1.ServiceAccount)
NoToken ensures the ServiceAccount's secrets list doesn't contain any reference to auto-generated tokens. Useful in tests that expect the creation of a ServiceAccount, when this list is supposed to always be empty.
func Populate ¶ added in v1.16.0
func Populate(rclCpy v1alpha1.Reconcilable)
Populate populates an component instance with generic attributes.
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.16.0
func TestReconcileAdapter(t *testing.T, ctor Ctor, rcl v1alpha1.Reconcilable, adapterBuilder interface{})
TestReconcileAdapter tests the Reconcile() method of the controller.Reconciler implemented by component Reconcilers, with focus on the generic ReconcileAdapter logic executed by the generic adapter reconciler embedded in every component Reconciler.
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
func ToUnstructured ¶ added in v1.14.1
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 ¶
type Ctor func(*testing.T, context.Context, *rt.TableRow, *Listers) controller.Reconciler
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 ¶
NewListers returns a new instance of Listers initialized with the given objects.
func (*Listers) GetDataWeaveTransformationLister ¶ added in v1.16.0
func (l *Listers) GetDataWeaveTransformationLister() flowlisters.DataWeaveTransformationLister
GetDataWeaveTransformationLister returns a Lister for DataWeaveTransformation objects.
func (*Listers) GetFlowObjects ¶ added in v1.16.0
GetFlowObjects returns objects from the flow API.
func (*Listers) GetJQTransformationLister ¶ added in v1.16.0
func (l *Listers) GetJQTransformationLister() flowlisters.JQTransformationLister
GetJQTransformationLister returns a Lister for JQTransformation objects.
func (*Listers) GetKubeObjects ¶
GetKubeObjects returns objects from Kubernetes APIs.
func (*Listers) GetRoleBindingLister ¶ added in v1.16.0
func (l *Listers) GetRoleBindingLister() rbaclistersv1.RoleBindingLister
GetRoleBindingLister returns a lister for RoleBinding objects
func (*Listers) GetServiceAccountLister ¶ added in v1.16.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 Service objects.
func (*Listers) GetServingObjects ¶
GetServingObjects returns objects from the serving API.
func (*Listers) GetSynchronizerLister ¶ added in v1.16.0
func (l *Listers) GetSynchronizerLister() flowlisters.SynchronizerLister
GetSynchronizerLister returns a Lister for Synchronizer objects.
func (*Listers) GetTransformationLister ¶ added in v1.16.0
func (l *Listers) GetTransformationLister() flowlisters.TransformationLister
GetTransformationLister returns a Lister for Transformation objects.
func (*Listers) GetXMLToJSONTransformationLister ¶ added in v1.16.0
func (l *Listers) GetXMLToJSONTransformationLister() flowlisters.XMLToJSONTransformationLister
GetXMLToJSONTransformationLister returns a Lister for XMLToJSONTransformation objects.
func (*Listers) GetXSLTTransformationLister ¶ added in v1.14.1
func (l *Listers) GetXSLTTransformationLister() flowlisters.XSLTTransformationLister
GetXSLTTransformationLister returns a Lister for XSLTTransformation objects.
type ServiceAccountCtorWithOptions ¶ added in v1.16.0
type ServiceAccountCtorWithOptions func(...resource.ServiceAccountOption) *corev1.ServiceAccount
ServiceAccountCtorWithOptions returns a ServiceAccount constructor which accepts options.
func NewServiceAccount ¶ added in v1.16.0
func NewServiceAccount(rcl v1alpha1.Reconcilable) ServiceAccountCtorWithOptions
NewServiceAccount returns a ServiceAccountCtorWithOptions for the given component instance.