cert-manager: github.com/jetstack/cert-manager/pkg/controller/test Index | Files

package test

import "github.com/jetstack/cert-manager/pkg/controller/test"

Package test contains testing utilities used for constructing fake Contexts which can be used during tests.

It should be used for all unit tests that require a set of fake clientsets etc in order to provide test consistency.


Package Files

actions.go context_builder.go doc.go reactors.go recorder.go util.go

func NTimesReactor Uses

func NTimesReactor(f coretesting.ReactionFunc, numberCalls int) coretesting.ReactionFunc

func ObjectCreatedReactor Uses

func ObjectCreatedReactor(t *testing.T, b *Builder, expectedObj runtime.Object) coretesting.ReactionFunc

func ObjectDeletedReactor Uses

func ObjectDeletedReactor(t *testing.T, b *Builder, obj runtime.Object) coretesting.ReactionFunc

func RandStringBytes Uses

func RandStringBytes(n int) string

type Action Uses

type Action interface {
    Action() coretesting.Action
    Matches(coretesting.Action) error

func NewAction Uses

func NewAction(a coretesting.Action) Action

func NewCustomMatch Uses

func NewCustomMatch(a coretesting.Action, matchFn ActionMatchFn) Action

type ActionMatchFn Uses

type ActionMatchFn func(coretesting.Action, coretesting.Action) error

type Builder Uses

type Builder struct {
    T   *testing.T

    KubeObjects        []runtime.Object
    CertManagerObjects []runtime.Object
    ExpectedActions    []Action
    ExpectedEvents     []string
    StringGenerator    StringGenerator

    // Clock will be the Clock set on the controller context.
    // If not specified, the RealClock will be used.
    Clock *fakeclock.FakeClock

    // CheckFn is a custom check function that will be executed when the
    // CheckAndFinish method is called on the builder, after all other checks.
    // It will be passed a reference to the Builder in order to access state,
    // as well as a list of all the arguments passed to the CheckAndFinish
    // function (typically the list of return arguments from the function under
    // test).
    CheckFn func(*Builder, ...interface{})

    // contains filtered or unexported fields

Builder is a structure used to construct new Contexts for use during tests. Currently, only KubeObjects and CertManagerObjects can be specified. These will be auto loaded into the constructed fake Clientsets. Call ToContext() to construct a new context using the given values.

func (*Builder) AllActionsExecuted Uses

func (b *Builder) AllActionsExecuted() error

func (*Builder) AllEventsCalled Uses

func (b *Builder) AllEventsCalled() error

func (*Builder) AllReactorsCalled Uses

func (b *Builder) AllReactorsCalled() error

func (*Builder) CheckAndFinish Uses

func (b *Builder) CheckAndFinish(args ...interface{})

CheckAndFinish will run ensure: all reactors are called, all actions are expected, and all events are as expected. It will then call the Builder's CheckFn, if defined.

func (*Builder) EnsureReactorCalled Uses

func (b *Builder) EnsureReactorCalled(testName string, fn coretesting.ReactionFunc) coretesting.ReactionFunc

func (*Builder) Events Uses

func (b *Builder) Events() []string

func (*Builder) FakeCMClient Uses

func (b *Builder) FakeCMClient() *cmfake.Clientset

func (*Builder) FakeCMInformerFactory Uses

func (b *Builder) FakeCMInformerFactory() informers.SharedInformerFactory

func (*Builder) FakeKubeClient Uses

func (b *Builder) FakeKubeClient() *kubefake.Clientset

func (*Builder) FakeKubeInformerFactory Uses

func (b *Builder) FakeKubeInformerFactory() kubeinformers.SharedInformerFactory

func (*Builder) Init Uses

func (b *Builder) Init()

Init will construct a new context for this builder and set default values for any unset fields.

func (*Builder) RegisterAdditionalSyncFuncs Uses

func (b *Builder) RegisterAdditionalSyncFuncs(fns ...cache.InformerSynced)

RegisterAdditionalSyncFuncs registers an additional InformerSynced function with the builder. When the Sync method is called, the builder will also wait for the given listers to be synced as well as the listers that were registered with the informer factories that the builder provides.

func (*Builder) Start Uses

func (b *Builder) Start()

func (*Builder) Stop Uses

func (b *Builder) Stop()

Stop will signal the informers to stop watching changes This method is *not* safe to be called concurrently

func (*Builder) Sync Uses

func (b *Builder) Sync()

type FakeRecorder Uses

type FakeRecorder struct {
    Events []string

FakeRecorder is used as a fake during tests. It is thread safe. It is usable when created manually and not by NewFakeRecorder, however all events may be thrown away in this case.

func (*FakeRecorder) AnnotatedEventf Uses

func (f *FakeRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})

func (*FakeRecorder) Event Uses

func (f *FakeRecorder) Event(object runtime.Object, eventtype, reason, message string)

func (*FakeRecorder) Eventf Uses

func (f *FakeRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

func (*FakeRecorder) PastEventf Uses

func (f *FakeRecorder) PastEventf(object runtime.Object, timestamp metav1.Time, eventtype, reason, messageFmt string, args ...interface{})

type StringGenerator Uses

type StringGenerator func(n int) string

func FixedString Uses

func FixedString(s string) StringGenerator

Package test imports 24 packages (graph). Updated 2020-08-12. Refresh now. Tools for package owners.