Documentation ¶
Index ¶
- Variables
- func CRDs() string
- func CheckCRDFiles(crds []string) ([]string, error)
- func Expand(path string) ([]string, error)
- func UseExistingCluster() bool
- type Env
- type MockClient
- func (c *MockClient) Create(ctx context.Context, obj runtime.Object) error
- func (c *MockClient) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOptionFunc) error
- func (c *MockClient) Get(ctx context.Context, key client.ObjectKey, obj runtime.Object) error
- func (c *MockClient) List(ctx context.Context, opts *client.ListOptions, list runtime.Object) error
- func (c *MockClient) Status() client.StatusWriter
- func (c *MockClient) Update(ctx context.Context, obj runtime.Object) error
- type MockStatusWriter
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 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
Start - starts and bootstraps test environment ang returns Kubernetes config instance
func (*Env) StartClient ¶ added in v0.2.0
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
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) 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) 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
type MockStatusWriter ¶ added in v0.2.0
MockStatusWriter provides mock functionality for status sub-resource