test

package
v0.0.0-...-68136ef Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 EqualConditionedStatus

func EqualConditionedStatus(x, y xpcorev1alpha1.ConditionedStatus) bool

EqualConditionedStatus checks ConditionedStatus for equality ignoring the actual order of the conditions

func EquateErrors

func EquateErrors() cmp.Option

EquateErrors returns true if the supplied errors are of the same type and produce identical strings. This mirrors the error comparison behaviour of https://github.com/go-test/deep, which most Crossplane tests targeted before we switched to go-cmp.

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 ConditionedStatusBuilder

type ConditionedStatusBuilder struct {
	*xpcorev1alpha1.ConditionedStatus
}

ConditionedStatusBuilder creates new ConditionedStatus

func NewConditionedStatusBuilder

func NewConditionedStatusBuilder() *ConditionedStatusBuilder

NewConditionedStatusBuilder - new builder

func (*ConditionedStatusBuilder) Build

Build returns new ConditionedStatus

func (*ConditionedStatusBuilder) WithFailedCondition

func (b *ConditionedStatusBuilder) WithFailedCondition(r, m string) *ConditionedStatusBuilder

WithFailedCondition sets and activates failed condition

func (*ConditionedStatusBuilder) WithReadyCondition

func (b *ConditionedStatusBuilder) WithReadyCondition() *ConditionedStatusBuilder

WithReadyCondition sets and activates ready condition

func (*ConditionedStatusBuilder) WithUnsetCondition

WithUnsetCondition deactivates condition of given type

type Env

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

Env - wrapper for controller-runtime envtest with additional functionality

func NewEnv

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

NewEnv - create new test environment instance

func (*Env) Start

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

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

func (*Env) StartClient

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

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

func (*Env) Stop

func (te *Env) Stop()

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

func (*Env) StopAndExit

func (te *Env) StopAndExit(code int)

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

type MockClient

type MockClient struct {
	MockGet          MockGetFn
	MockList         MockListFn
	MockCreate       MockCreateFn
	MockDelete       MockDeleteFn
	MockUpdate       MockUpdateFn
	MockStatusUpdate MockStatusUpdateFn
}

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

func NewMockClient() *MockClient

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

func (*MockClient) Create

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

Create calls MockClient's MockCreate function.

func (*MockClient) Delete

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

Delete calls MockClient's MockDelete function.

func (*MockClient) Get

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

Get calls MockClient's MockGet function.

func (*MockClient) List

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

List calls MockClient's MockList function.

func (*MockClient) Status

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

Status returns status writer for status sub-resource

func (*MockClient) Update

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

Update calls MockClient's MockUpdate function.

type MockCreateFn

type MockCreateFn func(ctx context.Context, obj runtime.Object) error

A MockCreateFn is used to mock client.Client's Create implementation.

func NewMockCreateFn

func NewMockCreateFn(err error) MockCreateFn

NewMockCreateFn returns a MockCreateFn that returns the supplied error.

type MockDeleteFn

type MockDeleteFn func(ctx context.Context, obj runtime.Object, opts ...client.DeleteOptionFunc) error

A MockDeleteFn is used to mock client.Client's Delete implementation.

func NewMockDeleteFn

func NewMockDeleteFn(err error) MockDeleteFn

NewMockDeleteFn returns a MockDeleteFn that returns the supplied error.

type MockGetFn

type MockGetFn func(ctx context.Context, key client.ObjectKey, obj runtime.Object) error

A MockGetFn is used to mock client.Client's Get implementation.

func NewMockGetFn

func NewMockGetFn(err error) MockGetFn

NewMockGetFn returns a MockGetFn that returns the supplied error.

type MockListFn

type MockListFn func(ctx context.Context, opts *client.ListOptions, list runtime.Object) error

A MockListFn is used to mock client.Client's List implementation.

func NewMockListFn

func NewMockListFn(err error) MockListFn

NewMockListFn returns a MockListFn that returns the supplied error.

type MockStatusUpdateFn

type MockStatusUpdateFn func(ctx context.Context, obj runtime.Object) error

A MockStatusUpdateFn is used to mock client.Client's StatusUpdate implementation.

func NewMockStatusUpdateFn

func NewMockStatusUpdateFn(err error) MockStatusUpdateFn

NewMockStatusUpdateFn returns a MockStatusUpdateFn that returns the supplied error.

type MockStatusWriter

type MockStatusWriter struct {
	MockUpdate MockStatusUpdateFn
}

MockStatusWriter provides mock functionality for status sub-resource

func (*MockStatusWriter) Update

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

Update status sub-resource

type MockUpdateFn

type MockUpdateFn func(ctx context.Context, obj runtime.Object) error

A MockUpdateFn is used to mock client.Client's Update implementation.

func NewMockUpdateFn

func NewMockUpdateFn(err error) MockUpdateFn

NewMockUpdateFn returns a MockUpdateFn that returns the supplied error.

Jump to

Keyboard shortcuts

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