{"modulePath":"github.com/markusthoemmes/knative-serving","version":"v0.1.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testing\n\nPackage testing includes utilities for testing controllers.\n\nPackage testing includes utilities for testing controllers.\n\n## Functions\n\n```go\nfunc InduceFailure(verb, resource string) clientgotesting.ReactionFunc\n```\nInduceFailure is used in conjunction with TableTest's WithReactors field. Tests that want to induce a failure in a row of a TableTest would add:\n\n\tWithReactors: []clientgotesting.ReactionFunc{\n\t   // Makes calls to create revisions return an error.\n\t   InduceFailure(\"create\", \"revisions\"),\n\t},\n\n```go\nfunc KeyOrDie(obj interface{}) string\n```\nKeyOrDie returns the string key of the Kubernetes object or panics if a key cannot be generated.\n\n```go\nfunc ValidateCreates(action clientgotesting.Action) (handled bool, ret runtime.Object, err error)\n```\n\n```go\nfunc ValidateUpdates(action clientgotesting.Action) (handled bool, ret runtime.Object, err error)\n```\n\n## Types\n\n```go\ntype BuildLister struct {\n\tErr   error\n\tItems []*buildv1alpha1.Build\n}\n```\nBuildLister is a lister.BuildLister fake for testing.\n\n```go\nfunc (r *BuildLister) Builds(namespace string) buildlisters.BuildNamespaceLister\n```\n\n```go\nfunc (r *BuildLister) List(selector labels.Selector) (results []*buildv1alpha1.Build, err error)\n```\n\n```go\ntype ConfigMapLister struct {\n\tErr   error\n\tItems []*corev1.ConfigMap\n}\n```\nConfigMapLister is a lister.ConfigMapLister fake for testing.\n\n```go\nfunc (r *ConfigMapLister) ConfigMaps(namespace string) corev1listers.ConfigMapNamespaceLister\n```\n\n```go\nfunc (r *ConfigMapLister) List(selector labels.Selector) (results []*corev1.ConfigMap, err error)\n```\n\n```go\ntype ConfigurationLister struct {\n\tErr   error\n\tItems []*v1alpha1.Configuration\n}\n```\nConfigurationLister is a lister.ConfigurationLister fake for testing.\n\n```go\nfunc (r *ConfigurationLister) Configurations(namespace string) listers.ConfigurationNamespaceLister\n```\n\n```go\nfunc (r *ConfigurationLister) List(selector labels.Selector) (results []*v1alpha1.Configuration, err error)\n```\n\n```go\ntype CreateHookFunc func(runtime.Object) HookResult\n```\nCreateHookFunc is a function for handling a Create hook. Its runtime.Object parameter will be the Kubernetes resource created. The resource can be cast to its actual type like this:\n\n\tpod := obj.(*v1.Pod)\n\nA return value of true marks the hook as completed. Returning false allows the hook to run again when the next resource of the requested type is created.\n\n```go\nfunc ExpectNormalEventDelivery(t *testing.T, messageRegexp string) CreateHookFunc\n```\nExpectNormalEventDelivery returns a hook function that can be passed to a Hooks.OnCreate() call to verify that an event of type Normal was created matching the given regular expression. For this expectation to be effective the test must also call Hooks.WaitForHooks().\n\n```go\nfunc ExpectWarningEventDelivery(t *testing.T, messageRegexp string) CreateHookFunc\n```\nExpectWarningEventDelivery returns a hook function that can be passed to a Hooks.OnCreate() call to verify that an event of type Warning was created matching the given regular expression. For this expectation to be effective the test must also call Hooks.WaitForHooks().\n\n```go\ntype Ctor func(*Listers, controller.Options) controller.Interface\n```\n\n```go\ntype DeleteHookFunc func(string) HookResult\n```\nDeleteHookFunc is a function for handling a delete hook. Its name parameter will be the name of the resource deleted. The resource itself is not available to the reactor.\n\n```go\ntype DeploymentLister struct {\n\tErr   error\n\tItems []*appsv1.Deployment\n}\n```\nDeploymentLister is a lister.DeploymentLister fake for testing.\n\n```go\nfunc (r *DeploymentLister) Deployments(namespace string) appsv1listers.DeploymentNamespaceLister\n```\n\n```go\nfunc (r *DeploymentLister) GetDeploymentsForReplicaSet(rs *appsv1.ReplicaSet) (results []*appsv1.Deployment, err error)\n```\n\n```go\nfunc (r *DeploymentLister) List(selector labels.Selector) (results []*appsv1.Deployment, err error)\n```\n\n```go\ntype EndpointsLister struct {\n\tErr   error\n\tItems []*corev1.Endpoints\n}\n```\nEndpointsLister is a lister.EndpointsLister fake for testing.\n\n```go\nfunc (r *EndpointsLister) Endpoints(namespace string) corev1listers.EndpointsNamespaceLister\n```\n\n```go\nfunc (r *EndpointsLister) List(selector labels.Selector) (results []*corev1.Endpoints, err error)\n```\n\n```go\ntype HookResult bool\n```\nHookResult is the return value of hook functions.\n\n```go\nconst (\n\t// HookComplete indicates the hook function completed, and WaitForHooks should\n\t// not wait for it.\n\tHookComplete HookResult = true\n\t// HookIncomplete indicates the hook function is incomplete, and WaitForHooks\n\t// should wait for it to complete.\n\tHookIncomplete HookResult = false\n)\n```\n\n```go\ntype Hooks struct {\n\t// contains filtered or unexported fields\n}\n```\nHooks is a utility struct that simplifies controller testing with fake clients. A Hooks struct allows attaching hook functions to actions (create, update, delete) on a specified resource type within a fake client and ensuring that all hooks complete in a timely manner.\n\n```go\nfunc NewHooks() *Hooks\n```\nNewHooks returns a Hooks struct that can be used to attach hooks to one or more fake clients and wait for all hooks to complete. TODO(grantr): Allow validating that a hook never fires\n\n```go\nfunc (h *Hooks) OnCreate(fake *kubetesting.Fake, resource string, rf CreateHookFunc)\n```\nOnCreate attaches a create hook to the given Fake. The hook function is executed every time a resource of the given type is created.\n\n```go\nfunc (h *Hooks) OnDelete(fake *kubetesting.Fake, resource string, rf DeleteHookFunc)\n```\nOnDelete attaches a delete hook to the given Fake. The hook function is executed every time a resource of the given type is deleted.\n\n```go\nfunc (h *Hooks) OnUpdate(fake *kubetesting.Fake, resource string, rf UpdateHookFunc)\n```\nOnUpdate attaches an update hook to the given Fake. The hook function is executed every time a resource of the given type is updated.\n\n```go\nfunc (h *Hooks) WaitForHooks(timeout time.Duration) error\n```\nWaitForHooks waits until all attached hooks have returned true at least once. If the given timeout expires before that happens, an error is returned.\n\n```go\ntype K8sServiceLister struct {\n\tErr   error\n\tItems []*corev1.Service\n}\n```\nK8sServiceLister is a lister.ServiceLister fake for testing.\n\n```go\nfunc (r *K8sServiceLister) GetPodServices(p *corev1.Pod) (results []*corev1.Service, err error)\n```\n\n```go\nfunc (r *K8sServiceLister) List(selector labels.Selector) (results []*corev1.Service, err error)\n```\n\n```go\nfunc (r *K8sServiceLister) Services(namespace string) corev1listers.ServiceNamespaceLister\n```\n\n```go\ntype Listers struct {\n\tService       *ServiceLister\n\tRoute         *RouteLister\n\tConfiguration *ConfigurationLister\n\tRevision      *RevisionLister\n\n\tVirtualService *VirtualServiceLister\n\n\tBuild *BuildLister\n\n\tDeployment *DeploymentLister\n\tK8sService *K8sServiceLister\n\tEndpoints  *EndpointsLister\n\tConfigMap  *ConfigMapLister\n}\n```\nListers holds the universe of objects that are available at the start of a reconciliation.\n\n```go\nfunc NewListers(objs []runtime.Object) Listers\n```\n\n```go\nfunc (f *Listers) GetBuildLister() *BuildLister\n```\n\n```go\nfunc (f *Listers) GetBuildObjects() []runtime.Object\n```\n\n```go\nfunc (f *Listers) GetConfigMapLister() *ConfigMapLister\n```\n\n```go\nfunc (f *Listers) GetConfigurationLister() *ConfigurationLister\n```\n\n```go\nfunc (f *Listers) GetDeploymentLister() *DeploymentLister\n```\n\n```go\nfunc (f *Listers) GetEndpointsLister() *EndpointsLister\n```\n\n```go\nfunc (f *Listers) GetK8sServiceLister() *K8sServiceLister\n```\n\n```go\nfunc (f *Listers) GetKubeObjects() []runtime.Object\n```\n\n```go\nfunc (f *Listers) GetRevisionLister() *RevisionLister\n```\n\n```go\nfunc (f *Listers) GetRouteLister() *RouteLister\n```\n\n```go\nfunc (f *Listers) GetServiceLister() *ServiceLister\n```\n\n```go\nfunc (f *Listers) GetServingObjects() []runtime.Object\n```\n\n```go\nfunc (f *Listers) GetVirtualServiceLister() *VirtualServiceLister\n```\n\n```go\ntype RevisionLister struct {\n\tErr   error\n\tItems []*v1alpha1.Revision\n}\n```\nRevisionLister is a lister.RevisionLister fake for testing.\n\n```go\nfunc (r *RevisionLister) List(selector labels.Selector) (results []*v1alpha1.Revision, err error)\n```\n\n```go\nfunc (r *RevisionLister) Revisions(namespace string) listers.RevisionNamespaceLister\n```\n\n```go\ntype RouteLister struct {\n\tErr   error\n\tItems []*v1alpha1.Route\n}\n```\nRouteLister is a lister.RouteLister fake for testing.\n\n```go\nfunc (r *RouteLister) List(selector labels.Selector) (results []*v1alpha1.Route, err error)\n```\n\n```go\nfunc (r *RouteLister) Routes(namespace string) listers.RouteNamespaceLister\n```\n\n```go\ntype ServiceLister struct {\n\tErr   error\n\tItems []*v1alpha1.Service\n}\n```\nServiceLister is a lister.ServiceLister fake for testing.\n\n```go\nfunc (r *ServiceLister) List(selector labels.Selector) (results []*v1alpha1.Service, err error)\n```\n\n```go\nfunc (r *ServiceLister) Services(namespace string) listers.ServiceNamespaceLister\n```\n\n```go\ntype TableRow struct {\n\t// Name is a descriptive name for this test suitable as a first argument to t.Run()\n\tName string\n\n\t// Objects holds the state of the world at the onset of reconciliation.\n\tObjects []runtime.Object\n\n\t// Key is the parameter to reconciliation.\n\t// This has the form \"namespace/name\".\n\tKey string\n\n\t// WantErr holds whether we should expect the reconciliation to result in an error.\n\tWantErr bool\n\n\t// WantCreates holds the set of Create calls we expect during reconciliation.\n\tWantCreates []metav1.Object\n\n\t// WantUpdates holds the set of Update calls we expect during reconciliation.\n\tWantUpdates []clientgotesting.UpdateActionImpl\n\n\t// WantDeletes holds the set of Delete calls we expect during reconciliation.\n\tWantDeletes []clientgotesting.DeleteActionImpl\n\n\t// WantQueue is the set of keys we expect to be in the workqueue following reconciliation.\n\tWantQueue []string\n\n\t// WithReactors is a set of functions that are installed as Reactors for the execution\n\t// of this row of the table-driven-test.\n\tWithReactors []clientgotesting.ReactionFunc\n}\n```\nTableRow holds a single row of our table test.\n\n```go\nfunc (r *TableRow) Test(t *testing.T, ctor Ctor)\n```\n\n```go\ntype TableTest []TableRow\n```\n\n```go\nfunc (tt TableTest) Test(t *testing.T, ctor Ctor)\n```\n\n```go\ntype UpdateHookFunc func(runtime.Object) HookResult\n```\nUpdateHookFunc is a function for handling an update hook. its runtime.Object parameter will be the Kubernetes resource updated. The resource can be cast to its actual type like this:\n\n\tpod := obj.(*v1.Pod)\n\nA return value of true marks the hook as completed. Returning false allows the hook to run again when the next resource of the requested type is updated.\n\n```go\ntype VirtualServiceLister struct {\n\tErr   error\n\tItems []*istiov1alpha3.VirtualService\n}\n```\nVirtualServiceLister is a istiolisters.VirtualServiceLister fake for testing.\n\n```go\nfunc (r *VirtualServiceLister) GetPodServices(p *corev1.Pod) (results []*istiov1alpha3.VirtualService, err error)\n```\n\n```go\nfunc (r *VirtualServiceLister) List(selector labels.Selector) (results []*istiov1alpha3.VirtualService, err error)\n```\n\n```go\nfunc (r *VirtualServiceLister) VirtualServices(namespace string) istiolisters.VirtualServiceNamespaceLister\n```\n\n","path":"github.com/markusthoemmes/knative-serving/pkg/controller/testing","name":"testing","synopsis":"Package testing includes utilities for testing controllers.","isRedistributable":true}
