Documentation ¶
Index ¶
- Variables
- func CheckCRDFiles(crds []string) ([]string, error)
- func EquateConditions() cmp.Option
- func EquateErrors() cmp.Option
- func Expand(path string) ([]string, error)
- func UseExistingCluster() *bool
- type Env
- type MockClient
- func (c *MockClient) Create(ctx context.Context, obj runtime.Object, opts ...client.CreateOption) error
- func (c *MockClient) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOption) error
- func (c *MockClient) DeleteAllOf(ctx context.Context, obj runtime.Object, opts ...client.DeleteAllOfOption) error
- func (c *MockClient) Get(ctx context.Context, key client.ObjectKey, obj runtime.Object) error
- func (c *MockClient) List(ctx context.Context, list runtime.Object, opts ...client.ListOption) error
- func (c *MockClient) Patch(ctx context.Context, obj runtime.Object, patch client.Patch, ...) error
- func (c *MockClient) Status() client.StatusWriter
- func (c *MockClient) Update(ctx context.Context, obj runtime.Object, opts ...client.UpdateOption) error
- type MockCreateFn
- type MockDeleteAllOfFn
- type MockDeleteFn
- type MockGetFn
- type MockListFn
- type MockPatchFn
- type MockStatusPatchFn
- type MockStatusUpdateFn
- type MockStatusWriter
- type MockUpdateFn
- type ObjectFn
Constants ¶
This section is empty.
Variables ¶
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 CheckCRDFiles ¶
CheckCRDFiles - validates that all crds files are found.
func EquateConditions ¶
EquateConditions sorts any slices of Condition before comparing them.
func EquateErrors ¶
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 UseExistingCluster ¶
func UseExistingCluster() *bool
UseExistingCluster - checks if USE_EXISTING_CLUSTER environment variable is set
Types ¶
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 ¶
Start - starts and bootstraps test environment ang returns Kubernetes config instance
func (*Env) StartClient ¶
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 ¶
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 MockDeleteAllOf MockDeleteAllOfFn MockUpdate MockUpdateFn MockPatch MockPatchFn MockStatusUpdate MockStatusUpdateFn MockStatusPatch MockStatusPatchFn }
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, opts ...client.CreateOption) error
Create calls MockClient's MockCreate function.
func (*MockClient) Delete ¶
func (c *MockClient) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOption) error
Delete calls MockClient's MockDelete function.
func (*MockClient) DeleteAllOf ¶
func (c *MockClient) DeleteAllOf(ctx context.Context, obj runtime.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf calls MockClient's DeleteAllOf function.
func (*MockClient) List ¶
func (c *MockClient) List(ctx context.Context, list runtime.Object, opts ...client.ListOption) error
List calls MockClient's MockList function.
func (*MockClient) Patch ¶
func (c *MockClient) Patch(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error
Patch calls MockClient's MockPatch 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, opts ...client.UpdateOption) error
Update calls MockClient's MockUpdate function.
type MockCreateFn ¶
A MockCreateFn is used to mock client.Client's Create implementation.
func NewMockCreateFn ¶
func NewMockCreateFn(err error, ofn ...ObjectFn) MockCreateFn
NewMockCreateFn returns a MockCreateFn that returns the supplied error.
type MockDeleteAllOfFn ¶
type MockDeleteAllOfFn func(ctx context.Context, obj runtime.Object, opts ...client.DeleteAllOfOption) error
A MockDeleteAllOfFn is used to mock client.Client's Delete implementation.
func NewMockDeleteAllOfFn ¶
func NewMockDeleteAllOfFn(err error, ofn ...ObjectFn) MockDeleteAllOfFn
NewMockDeleteAllOfFn returns a MockDeleteAllOfFn that returns the supplied error.
type MockDeleteFn ¶
A MockDeleteFn is used to mock client.Client's Delete implementation.
func NewMockDeleteFn ¶
func NewMockDeleteFn(err error, ofn ...ObjectFn) MockDeleteFn
NewMockDeleteFn returns a MockDeleteFn that returns the supplied error.
type MockGetFn ¶
A MockGetFn is used to mock client.Client's Get implementation.
func NewMockGetFn ¶
NewMockGetFn returns a MockGetFn that returns the supplied error.
type MockListFn ¶
A MockListFn is used to mock client.Client's List implementation.
func NewMockListFn ¶
func NewMockListFn(err error, ofn ...ObjectFn) MockListFn
NewMockListFn returns a MockListFn that returns the supplied error.
type MockPatchFn ¶
type MockPatchFn func(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error
A MockPatchFn is used to mock client.Client's Patch implementation.
func NewMockPatchFn ¶
func NewMockPatchFn(err error, ofn ...ObjectFn) MockPatchFn
NewMockPatchFn returns a MockPatchFn that returns the supplied error.
type MockStatusPatchFn ¶
type MockStatusPatchFn func(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error
A MockStatusPatchFn is used to mock client.Client's StatusUpdate implementation.
func NewMockStatusPatchFn ¶
func NewMockStatusPatchFn(err error, ofn ...ObjectFn) MockStatusPatchFn
NewMockStatusPatchFn returns a MockStatusPatchFn that returns the supplied error.
type MockStatusUpdateFn ¶
type MockStatusUpdateFn func(ctx context.Context, obj runtime.Object, opts ...client.UpdateOption) error
A MockStatusUpdateFn is used to mock client.Client's StatusUpdate implementation.
func NewMockStatusUpdateFn ¶
func NewMockStatusUpdateFn(err error, ofn ...ObjectFn) MockStatusUpdateFn
NewMockStatusUpdateFn returns a MockStatusUpdateFn that returns the supplied error.
type MockStatusWriter ¶
type MockStatusWriter struct { MockUpdate MockStatusUpdateFn MockPatch MockStatusPatchFn }
MockStatusWriter provides mock functionality for status sub-resource
func (*MockStatusWriter) Patch ¶
func (m *MockStatusWriter) Patch(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.PatchOption) error
Patch mocks the patch method
func (*MockStatusWriter) Update ¶
func (m *MockStatusWriter) Update(ctx context.Context, obj runtime.Object, opts ...client.UpdateOption) error
Update status sub-resource
type MockUpdateFn ¶
A MockUpdateFn is used to mock client.Client's Update implementation.
func NewMockUpdateFn ¶
func NewMockUpdateFn(err error, ofn ...ObjectFn) MockUpdateFn
NewMockUpdateFn returns a MockUpdateFn that returns the supplied error.