test

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetry = wait.Backoff{
	Steps:    500,
	Duration: 10 * time.Millisecond,
	Factor:   1.0,
	Jitter:   0.1,
}

DefaultRetry is the recommended retry parameters for unit testing scenarios where a condition is being tested multiple times before it is expected to succeed.

Functions

func CRDs

func CRDs() string

CRDs path to project crds location

func CheckCRDFiles

func CheckCRDFiles(crds []string) ([]string, error)

CheckCRDFiles - validates that all crds files are found.

func Expand

func Expand(path string) ([]string, error)

Expand recursively and returns list of all sub-directories (if any)

func UseExistingCluster

func UseExistingCluster() bool

UseExistingCluster - checks if USE_EXISTING_CLUSTER environment variable is set

Types

type Env added in v0.2.0

type Env struct {
	envtest.Environment
	// contains filtered or unexported fields
}

Env - wrapper for controller-runtime envtest with additional functionality

func NewEnv added in v0.2.0

func NewEnv(namespace string, builder apiruntime.SchemeBuilder, crds ...string) *Env

NewEnv - create new test environment instance

func (*Env) Start added in v0.2.0

func (te *Env) Start() *rest.Config

Start - starts and bootstraps test environment ang returns Kubernetes config instance

func (*Env) StartClient added in v0.2.0

func (te *Env) StartClient() client.Client

StartClient - starts test environment and returns instance of go-client

func (*Env) Stop added in v0.2.0

func (te *Env) Stop()

Stop - stops test environment performing additional cleanup (if needed)

func (*Env) StopAndExit added in v0.2.0

func (te *Env) StopAndExit(code int)

StopAndExit - stops and exists, typically used as a last call in TestMain

type MockClient added in v0.2.0

type MockClient struct {
	MockGet          func(ctx context.Context, key client.ObjectKey, obj runtime.Object) error
	MockList         func(ctx context.Context, opts *client.ListOptions, list runtime.Object) error
	MockCreate       func(ctx context.Context, obj runtime.Object) error
	MockDelete       func(ctx context.Context, obj runtime.Object, opts ...client.DeleteOptionFunc) error
	MockUpdate       func(ctx context.Context, obj runtime.Object) error
	MockStatusUpdate func(ctx context.Context, obj runtime.Object) error
}

MockClient implements controller-runtime's Client interface, allowing each method to be overridden for testing. The controller-runtime provides a fake client, but it is has surprising side effects (e.g. silently calling os.Exit(1)) and does not allow us control over the errors it returns.

func NewMockClient added in v0.2.0

func NewMockClient() *MockClient

NewMockClient returns a MockClient that does nothing when its methods are called.

func (*MockClient) Create added in v0.2.0

func (c *MockClient) Create(ctx context.Context, obj runtime.Object) error

Create calls MockClient's MockCreate function.

func (*MockClient) Delete added in v0.2.0

func (c *MockClient) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOptionFunc) error

Delete calls MockClient's MockDelete function.

func (*MockClient) Get added in v0.2.0

func (c *MockClient) Get(ctx context.Context, key client.ObjectKey, obj runtime.Object) error

Get calls MockClient's MockGet function.

func (*MockClient) List added in v0.2.0

func (c *MockClient) List(ctx context.Context, opts *client.ListOptions, list runtime.Object) error

List calls MockClient's MockList function.

func (*MockClient) Status added in v0.2.0

func (c *MockClient) Status() client.StatusWriter

Status returns status writer for status sub-resource

func (*MockClient) Update added in v0.2.0

func (c *MockClient) Update(ctx context.Context, obj runtime.Object) error

Update calls MockClient's MockUpdate function.

type MockStatusWriter added in v0.2.0

type MockStatusWriter struct {
	MockUpdate func(ctx context.Context, obj runtime.Object) error
}

MockStatusWriter provides mock functionality for status sub-resource

func (*MockStatusWriter) Update added in v0.2.0

func (m *MockStatusWriter) Update(ctx context.Context, obj runtime.Object) error

Update status sub-resource

Jump to

Keyboard shortcuts

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