testing

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockWorkQueue

type MockWorkQueue struct {
	workqueue.RateLimitingInterface
	// contains filtered or unexported fields
}

MockWorkQueue is a helper workqueue which can be wrapped around any RateLimitingInterface implementing queue. This allows synchronous testing of the controller. The typical pattern is:

mockQueue.ExpectAdd(3)
vmSource.Add(vm)
vmSource.Add(vm1)
vmSource.Add(vm2)
mockQueue.Wait()

This ensures that informer callbacks which are listening on vmSource enqueued three times an object. Since enqueing is typically the last action in listener callbacks, we can assume that the wanted scenario for a controller is set up, and an execution will process this scenario.

func NewMockWorkQueue

func NewMockWorkQueue(queue workqueue.RateLimitingInterface) *MockWorkQueue

func (*MockWorkQueue) Add

func (q *MockWorkQueue) Add(obj interface{})

func (*MockWorkQueue) ExpectAdds

func (q *MockWorkQueue) ExpectAdds(diff int)

ExpectAdds allows setting the amount of expected enqueues.

func (*MockWorkQueue) Wait

func (q *MockWorkQueue) Wait()

Wait waits until the expected amount of ExpectedAdds has happened. It will not block if there were no expectations set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL