Documentation ¶
Overview ¶
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.
Index ¶
- func NTimesReactor(f coretesting.ReactionFunc, numberCalls int) coretesting.ReactionFunc
- func ObjectCreatedReactor(t *testing.T, b *Builder, expectedObj runtime.Object) coretesting.ReactionFunc
- func ObjectDeletedReactor(t *testing.T, b *Builder, obj runtime.Object) coretesting.ReactionFunc
- func RandStringBytes(n int) string
- type Action
- type ActionMatchFn
- type Builder
- func (b *Builder) AllActionsExecuted() error
- func (b *Builder) AllReactorsCalled() error
- func (b *Builder) EnsureReactorCalled(testName string, fn coretesting.ReactionFunc) coretesting.ReactionFunc
- func (b *Builder) Events() []string
- func (b *Builder) FakeCMClient() *cmfake.Clientset
- func (b *Builder) FakeCMInformerFactory() informers.SharedInformerFactory
- func (b *Builder) FakeEventRecorder() *record.FakeRecorder
- func (b *Builder) FakeKubeClient() *kubefake.Clientset
- func (b *Builder) FakeKubeInformerFactory() kubeinformers.SharedInformerFactory
- func (b *Builder) Start()
- func (b *Builder) Stop()
- func (b *Builder) Sync()
- func (b *Builder) WaitForResync()
- type StringGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NTimesReactor ¶
func NTimesReactor(f coretesting.ReactionFunc, numberCalls int) coretesting.ReactionFunc
func ObjectCreatedReactor ¶
func ObjectCreatedReactor(t *testing.T, b *Builder, expectedObj runtime.Object) coretesting.ReactionFunc
func ObjectDeletedReactor ¶
func ObjectDeletedReactor(t *testing.T, b *Builder, obj runtime.Object) coretesting.ReactionFunc
func RandStringBytes ¶
Types ¶
type Action ¶
type Action interface { Action() coretesting.Action Matches(coretesting.Action) error }
func NewAction ¶
func NewAction(a coretesting.Action) Action
func NewCustomMatch ¶
func NewCustomMatch(a coretesting.Action, matchFn ActionMatchFn) Action
type ActionMatchFn ¶
type ActionMatchFn func(coretesting.Action, coretesting.Action) error
type Builder ¶
type Builder struct { T *testing.T KubeObjects []runtime.Object CertManagerObjects []runtime.Object ExpectedActions []Action StringGenerator StringGenerator *controller.Context // 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 ¶
func (*Builder) AllReactorsCalled ¶
func (*Builder) EnsureReactorCalled ¶
func (b *Builder) EnsureReactorCalled(testName string, fn coretesting.ReactionFunc) coretesting.ReactionFunc
func (*Builder) FakeCMClient ¶
func (*Builder) FakeCMInformerFactory ¶
func (b *Builder) FakeCMInformerFactory() informers.SharedInformerFactory
func (*Builder) FakeEventRecorder ¶
func (b *Builder) FakeEventRecorder() *record.FakeRecorder
func (*Builder) FakeKubeClient ¶
func (*Builder) FakeKubeInformerFactory ¶
func (b *Builder) FakeKubeInformerFactory() kubeinformers.SharedInformerFactory
func (*Builder) Start ¶
func (b *Builder) Start()
ToContext will construct a new context for this builder. Subsequent calls to ToContext will return the same Context instance.
func (*Builder) Stop ¶
func (b *Builder) Stop()
Stop will signal the informers to stop watching changes This method is *not* safe to be called concurrently
func (*Builder) WaitForResync ¶
func (b *Builder) WaitForResync()
WaitForResync will wait for the informer factory informer duration by calling time.Sleep. This will ensure that all informer Stores are up to date with current information from the fake clients.
type StringGenerator ¶
func FixedString ¶
func FixedString(s string) StringGenerator