controllertest

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: Apache-2.0 Imports: 24 Imported by: 1

README

Package controllertest

This package contains test utilities for controllers, including mocks and common helper functions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMockAWSConfigLoader added in v1.2.0

func CreateMockAWSConfigLoader() AWSConfigLoader

func CreateMockAutoscalingClientProvider added in v1.2.0

func CreateMockAutoscalingClientProvider(applicationAutoscalingClient applicationautoscalingiface.ApplicationAutoScalingAPI) ApplicationAutoscalingClientProvider

CreateMockAutoscalingClientProvider Create a provider that creates a mock ApplicationAutoscaling client.

func CreateMockAutoscalingClientWrapperProvider added in v1.2.0

func CreateMockAutoscalingClientWrapperProvider(applicationAutoscalingClient applicationautoscalingiface.ApplicationAutoScalingAPI) clientwrapper.ApplicationAutoscalingClientWrapperProvider

CreateMockAutoscalingClientWrapperProvider Creates a provider that creates a mock Application client wrapper.

func CreateMockNamespace added in v1.2.0

func CreateMockNamespace(ctx context.Context, k8sClient client.Client, k8sNamespace string) error

func CreateMockSageMakerClientProvider

func CreateMockSageMakerClientProvider(sageMakerClient sagemakeriface.SageMakerAPI) SageMakerClientProvider

Create a provider that creates a mock SageMaker client.

func CreateMockSageMakerClientWrapperProvider

func CreateMockSageMakerClientWrapperProvider(sageMakerClient sagemakeriface.SageMakerAPI) clientwrapper.SageMakerClientWrapperProvider

Create a provider that creates a mock SageMaker client wrapper.

func CreateReconciliationRequest

func CreateReconciliationRequest(name string, namespace string) ctrl.Request

Helper function to create a ctrl.Request.

func ExpectNoRequeue

func ExpectNoRequeue(result ctrl.Result, err error)

Expect the controller return value to be NoRequeue

func ExpectRequeueAfterInterval

func ExpectRequeueAfterInterval(result ctrl.Result, err error, pollDuration string)

Expect the controller return value to be RequeueAfterInterval, with the poll duration specified.

func ExpectRequeueImmediately

func ExpectRequeueImmediately(result ctrl.Result, err error)

Expect the controller return value to be RequeueImmediately.

func ParseDurationOrFail

func ParseDurationOrFail(str string) time.Duration

func ToBoolPtr

func ToBoolPtr(b bool) *bool

func ToFloat64Ptr

func ToFloat64Ptr(f float64) *float64

func ToInt64Ptr

func ToInt64Ptr(i int64) *int64

func ToIntPtr

func ToIntPtr(i int) *int

func ToStringPtr

func ToStringPtr(str string) *string

Types

type FailTestOnCreateK8sClient

type FailTestOnCreateK8sClient struct {
	client.Writer
	client.Reader
	client.StatusClient

	ActualClient client.Client
}

Make test fail on Create.

func (FailTestOnCreateK8sClient) Create

Make test fail.

func (FailTestOnCreateK8sClient) Get

Get should work normally.

func (FailTestOnCreateK8sClient) List

List should work normally.

func (FailTestOnCreateK8sClient) Update

Update should work normally.

type FailTestOnGetK8sClient

type FailTestOnGetK8sClient struct {
	client.Writer
	client.Reader
	client.StatusClient
}

Make test fail on Get.

func (FailTestOnGetK8sClient) Get

Make test fail.

type FailToCreateK8sClient

type FailToCreateK8sClient struct {
	client.Writer
	client.Reader
	client.StatusClient

	ActualClient client.Client
}

Mock of Kubernetes client.Client that always returns error when Create is invoked.

func (FailToCreateK8sClient) Create

Always return error on Create.

func (FailToCreateK8sClient) Get

Get should work normally.

func (FailToCreateK8sClient) List

List should work normally.

type FailToGetK8sClient

type FailToGetK8sClient struct {
	client.Writer
	client.Reader
	client.StatusClient
}

Mock of Kubernetes client.Client that always returns error when Get is invoked. TODO Should merge all k8s client mocks to a single, flexible mock.

func (FailToGetK8sClient) Get

Always return error.

type FailToListK8sClient

type FailToListK8sClient struct {
	client.Writer
	client.Reader
	client.StatusClient
}

Mock of Kubernetes client.Client that always returns error when List is invoked.

func (FailToListK8sClient) List

Always return error.

type FailToUpdateK8sClient

type FailToUpdateK8sClient struct {
	client.Writer
	client.Reader
	client.StatusClient

	ActualClient client.Client
}

Mock of Kubernetes client.Client that always returns error when Update is invoked.

func (FailToUpdateK8sClient) Get

Get should work normally.

func (FailToUpdateK8sClient) Status

Status should always return a mock status writer with Update patched.

func (FailToUpdateK8sClient) Update

Update should always return error on Update.

type FailToUpdateK8sStatusWriter

type FailToUpdateK8sStatusWriter struct {
	client.StatusWriter
}

func (FailToUpdateK8sStatusWriter) Update

Update should always return an error.

type MockAutoscalingClientBuilder added in v1.2.0

type MockAutoscalingClientBuilder struct {
	// contains filtered or unexported fields
}

MockAutoscalingClientBuilder is a Builder for mock Autoscaling API clients

func NewMockAutoscalingClientBuilder added in v1.2.0

func NewMockAutoscalingClientBuilder(testReporter GinkgoTInterface) *MockAutoscalingClientBuilder

NewMockAutoscalingClientBuilder returns a MockAuoscalingClientBuilder

func (*MockAutoscalingClientBuilder) AddDeleteScalingPolicyErrorResponse added in v1.2.0

func (m *MockAutoscalingClientBuilder) AddDeleteScalingPolicyErrorResponse(code string, message string, statusCode int, reqID string) *MockAutoscalingClientBuilder

AddDeleteScalingPolicyErrorResponse Add a PutScalingPolicy error response to the client.

func (*MockAutoscalingClientBuilder) AddDeleteScalingPolicyResponse added in v1.2.0

AddDeleteScalingPolicyResponse Add a PutScalingPolicy response to the client.

func (*MockAutoscalingClientBuilder) AddDeregisterScalableTargetsErrorResponse added in v1.2.0

func (m *MockAutoscalingClientBuilder) AddDeregisterScalableTargetsErrorResponse(code string, message string, statusCode int, reqID string) *MockAutoscalingClientBuilder

AddDeregisterScalableTargetsErrorResponse Add a PutScalingPolicy error response to the client.

func (*MockAutoscalingClientBuilder) AddDeregisterScalableTargetsResponse added in v1.2.0

AddDeregisterScalableTargetsResponse Add a PutScalingPolicy response to the client.

func (*MockAutoscalingClientBuilder) AddDescribeScalableTargetsErrorResponse added in v1.2.0

func (m *MockAutoscalingClientBuilder) AddDescribeScalableTargetsErrorResponse(code string, message string, statusCode int, reqID string) *MockAutoscalingClientBuilder

AddDescribeScalableTargetsErrorResponse Add a DescribeScalingPolicy error response to the client.

func (*MockAutoscalingClientBuilder) AddDescribeScalableTargetsResponse added in v1.2.0

AddDescribeScalableTargetsResponse Add a DescribeScalingPolicy response to the client.

func (*MockAutoscalingClientBuilder) AddDescribeScalingPoliciesEmptyResponse added in v1.2.0

func (m *MockAutoscalingClientBuilder) AddDescribeScalingPoliciesEmptyResponse() *MockAutoscalingClientBuilder

AddDescribeScalingPoliciesEmptyResponse Add a DescribeScalingPolicy response to the client.

func (*MockAutoscalingClientBuilder) AddDescribeScalingPoliciesErrorResponse added in v1.2.0

func (m *MockAutoscalingClientBuilder) AddDescribeScalingPoliciesErrorResponse(code string, message string, statusCode int, reqID string) *MockAutoscalingClientBuilder

AddDescribeScalingPoliciesErrorResponse Add a DescribeScalingPolicy error response to the client.

func (*MockAutoscalingClientBuilder) AddDescribeScalingPoliciesResponse added in v1.2.0

AddDescribeScalingPoliciesResponse Add a DescribeScalingPolicy response to the client.

func (*MockAutoscalingClientBuilder) AddPutScalingPolicyErrorResponse added in v1.2.0

func (m *MockAutoscalingClientBuilder) AddPutScalingPolicyErrorResponse(code string, message string, statusCode int, reqID string) *MockAutoscalingClientBuilder

AddPutScalingPolicyErrorResponse Add a PutScalingPolicy error response to the client.

func (*MockAutoscalingClientBuilder) AddPutScalingPolicyResponse added in v1.2.0

AddPutScalingPolicyResponse Add a PutScalingPolicy response to the client.

func (*MockAutoscalingClientBuilder) AddRegisterScalableTargetsErrorResponse added in v1.2.0

func (m *MockAutoscalingClientBuilder) AddRegisterScalableTargetsErrorResponse(code string, message string, statusCode int, reqID string) *MockAutoscalingClientBuilder

AddRegisterScalableTargetsErrorResponse Add a PutScalingPolicy error response to the client.

func (*MockAutoscalingClientBuilder) AddRegisterScalableTargetsResponse added in v1.2.0

AddRegisterScalableTargetsResponse Add a PutScalingPolicy response to the client.

func (*MockAutoscalingClientBuilder) Build added in v1.2.0

Build Create a mock ApplicationAutoscaling API client given configuration.

func (*MockAutoscalingClientBuilder) WithRequestList added in v1.2.0

func (m *MockAutoscalingClientBuilder) WithRequestList(requests *List) *MockAutoscalingClientBuilder

WithRequestList Store requests received by the mock client in a user-provided list.

type MockSageMakerClientBuilder

type MockSageMakerClientBuilder struct {
	// contains filtered or unexported fields
}

Builder for mock SageMaker API clients.

func NewMockSageMakerClientBuilder

func NewMockSageMakerClientBuilder(testReporter GinkgoTInterface) *MockSageMakerClientBuilder

func (*MockSageMakerClientBuilder) AddCreateEndpointConfigErrorResponse

func (m *MockSageMakerClientBuilder) AddCreateEndpointConfigErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a CreateEndpointConfig error response to the client.

func (*MockSageMakerClientBuilder) AddCreateEndpointConfigResponse

Add a CreateEndpointConfig response to the client.

func (*MockSageMakerClientBuilder) AddCreateEndpointErrorResponse

func (m *MockSageMakerClientBuilder) AddCreateEndpointErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a CreateEndpoint error response to the client.

func (*MockSageMakerClientBuilder) AddCreateEndpointResponse

Add a CreateEndpoint response to the client.

func (*MockSageMakerClientBuilder) AddCreateHyperParameterTuningJobErrorResponse

func (m *MockSageMakerClientBuilder) AddCreateHyperParameterTuningJobErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a CreateHyperParameterTuningJob error response to the client.

func (*MockSageMakerClientBuilder) AddCreateHyperParameterTuningJobResponse

Add a CreateHyperParameterTuningJob response to the client.

func (*MockSageMakerClientBuilder) AddCreateModelErrorResponse

func (m *MockSageMakerClientBuilder) AddCreateModelErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a CreateModel error response to the client.

func (*MockSageMakerClientBuilder) AddCreateModelResponse

Add a CreateModel response to the client.

func (*MockSageMakerClientBuilder) AddCreateProcessingJobErrorResponse added in v1.2.0

func (m *MockSageMakerClientBuilder) AddCreateProcessingJobErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

AddCreateProcessingJobErrorResponse returns an error response to the client.

func (*MockSageMakerClientBuilder) AddCreateProcessingJobResponse added in v1.2.0

AddCreateProcessingJobResponse adds a CreateProcessingJob response to the client.

func (*MockSageMakerClientBuilder) AddCreateTrainingJobResponse

Add a CreateTrainingJob response to the client.

func (*MockSageMakerClientBuilder) AddDeleteEndpointConfigErrorResponse

func (m *MockSageMakerClientBuilder) AddDeleteEndpointConfigErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DeleteEndpointConfig error response to the client.

func (*MockSageMakerClientBuilder) AddDeleteEndpointConfigResponse

Add a DeleteEndpointConfig response to the client.

func (*MockSageMakerClientBuilder) AddDeleteEndpointErrorResponse

func (m *MockSageMakerClientBuilder) AddDeleteEndpointErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DeleteEndpoint error response to the client.

func (*MockSageMakerClientBuilder) AddDeleteEndpointResponse

Add a DeleteEndpoint response to the client.

func (*MockSageMakerClientBuilder) AddDeleteModelErrorResponse

func (m *MockSageMakerClientBuilder) AddDeleteModelErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DeleteModel error response to the client.

func (*MockSageMakerClientBuilder) AddDeleteModelResponse

Add a DeleteModel response to the client.

func (*MockSageMakerClientBuilder) AddDescribeEndpointConfigErrorResponse

func (m *MockSageMakerClientBuilder) AddDescribeEndpointConfigErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DescribeEndpointConfig error response to the client.

func (*MockSageMakerClientBuilder) AddDescribeEndpointConfigResponse

Add a DescribeEndpointConfig response to the client.

func (*MockSageMakerClientBuilder) AddDescribeEndpointErrorResponse

func (m *MockSageMakerClientBuilder) AddDescribeEndpointErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DescribeEndpoint error response to the client.

func (*MockSageMakerClientBuilder) AddDescribeEndpointResponse

Add a DescribeEndpoint response to the client.

func (*MockSageMakerClientBuilder) AddDescribeHyperParameterTuningJobErrorResponse

func (m *MockSageMakerClientBuilder) AddDescribeHyperParameterTuningJobErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DescribeHyperParameterTuningJob error response to the client which has messsage too.

func (*MockSageMakerClientBuilder) AddDescribeHyperParameterTuningJobResponse

Add a DescribeHyperParameterTuningJob response to the client.

func (*MockSageMakerClientBuilder) AddDescribeModelErrorResponse

func (m *MockSageMakerClientBuilder) AddDescribeModelErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DescribeModel error response to the client.

func (*MockSageMakerClientBuilder) AddDescribeModelResponse

Add a DescribeModel response to the client.

func (*MockSageMakerClientBuilder) AddDescribeProcessingJobErrorResponse added in v1.2.0

func (m *MockSageMakerClientBuilder) AddDescribeProcessingJobErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

AddDescribeProcessingJobErrorResponse returns an error response to the client.

func (*MockSageMakerClientBuilder) AddDescribeProcessingJobResponse added in v1.2.0

AddDescribeProcessingJobResponse returns a DescribeProcessingJob response to the client.

func (*MockSageMakerClientBuilder) AddDescribeTrainingJobErrorResponse

func (m *MockSageMakerClientBuilder) AddDescribeTrainingJobErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a DescribeTrainingJob error response to the client.

func (*MockSageMakerClientBuilder) AddDescribeTrainingJobResponse

Add a DescribeTrainingJob response to the client.

func (*MockSageMakerClientBuilder) AddDescribeTransformJobErrorResponse

func (m *MockSageMakerClientBuilder) AddDescribeTransformJobErrorResponse(code string, statusCode int, reqId, message string) *MockSageMakerClientBuilder

Add a DescribeTrainingJob error response to the client.

func (*MockSageMakerClientBuilder) AddDescribeTransformJobResponse

Add a DescribeTransformJob response to the client.

func (*MockSageMakerClientBuilder) AddListTrainingJobsForHyperParameterTuningJobErrorResponse

func (m *MockSageMakerClientBuilder) AddListTrainingJobsForHyperParameterTuningJobErrorResponse(code string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a ListTrainingJobsForHyperParameterTuningJob error response to the client.

func (*MockSageMakerClientBuilder) AddListTrainingJobsForHyperParameterTuningJobResponse

func (m *MockSageMakerClientBuilder) AddListTrainingJobsForHyperParameterTuningJobResponse(data sagemaker.ListTrainingJobsForHyperParameterTuningJobOutput) *MockSageMakerClientBuilder

Add a ListTrainingJobsForHyperParameterTuningJob response to the client.

func (*MockSageMakerClientBuilder) AddStopHyperParameterTuningJobResponse

Add a StopHyperParameterTuningJob response to the client.

func (*MockSageMakerClientBuilder) AddStopProcessingJobResponse added in v1.2.0

AddStopProcessingJobResponse adds a StopProcessingJob response to the client.

func (*MockSageMakerClientBuilder) AddStopTrainingJobErrorResponse

func (m *MockSageMakerClientBuilder) AddStopTrainingJobErrorResponse(code string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a StopTrainingJob error response to the client.

func (*MockSageMakerClientBuilder) AddStopTrainingJobResponse

Add a StopTrainingJob response to the client.

func (*MockSageMakerClientBuilder) AddStopTransformJobResponse

Add a AddStopTransformJobResponse response to the client.

func (*MockSageMakerClientBuilder) AddUpdateEndpointErrorResponse

func (m *MockSageMakerClientBuilder) AddUpdateEndpointErrorResponse(code string, message string, statusCode int, reqId string) *MockSageMakerClientBuilder

Add a UpdateEndpoint error response to the client.

func (*MockSageMakerClientBuilder) AddUpdateEndpointResponse

Add a UpdateEndpoint response to the client.

func (*MockSageMakerClientBuilder) Build

Create a mock SageMaker API client given configuration.

func (*MockSageMakerClientBuilder) GetAddedResponsesLen

func (m *MockSageMakerClientBuilder) GetAddedResponsesLen() int

Get how many responses were added to the mock SageMaker client.

func (*MockSageMakerClientBuilder) WithRequestList

func (m *MockSageMakerClientBuilder) WithRequestList(requests *List) *MockSageMakerClientBuilder

Store requests received by the mock client in a user-provided list.

Jump to

Keyboard shortcuts

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