Documentation ¶
Overview ¶
Package testutil is a generated GoMock package.
Index ¶
- func Assert(t Failable, m gomock.Matcher, actual interface{})
- func AssertContainsAll(t Failable, haystack string, needles []string)
- func AssertEqual(t Failable, fieldName string, expected, actual interface{})
- func AssertErrorContainsAll(t Failable, errorMsg error, expected []string)
- func AssertErrorsEqual(t Failable, expected, actual error)
- func AssertFalse(t Failable, fieldName string, predicate bool)
- func AssertGolden(t Failable, fieldName string, bytes []byte)
- func AssertGoldenContext(t Failable, fieldName string, actualValue []byte, ...)
- func AssertGoldenJSON(t Failable, fieldName string, object interface{})
- func AssertGoldenJSONContext(t Failable, fieldName string, object interface{}, ...)
- func AssertJSONEqual(t Failable, expected, actual string)
- func AssertKeyWithValue(t Failable, m map[interface{}]interface{}, key, value interface{})
- func AssertNil(t Failable, name string, value interface{})
- func AssertNotBlank(t Failable, name string, value string)
- func AssertNotNil(t Failable, name string, value interface{})
- func AssertRegexp(t Failable, fieldName, pattern, actual string)
- func AssertRetrySucceeds(ctx context.Context, t Failable, times int, delay time.Duration, ...)
- func AssertTrue(t Failable, fieldName string, predicate bool)
- func AssertUnstructuredEqual(t *testing.T, field string, expected interface{}, u *unstructured.Unstructured)
- func Retry(ctx context.Context, times int, delay time.Duration, callback func() error) error
- func WithFeatureFlags(ctx context.Context, t *testing.T, ff map[string]bool) context.Context
- func WithGomockController(t *testing.T, f func(ctrl *gomock.Controller))
- type ApisDefaultableTest
- type ApisDefaultableTestSuite
- type ApisValidatableTest
- type ApisValidatableTestSuite
- type Failable
- type FakeApiServer
- func (m *FakeApiServer) Create(arg0 schema.GroupVersionResource, arg1 string, arg2 runtime.Object) (runtime.Object, error)
- func (m *FakeApiServer) Delete(arg0 schema.GroupVersionResource, arg1, arg2 string) error
- func (m *FakeApiServer) EXPECT() *FakeApiServerMockRecorder
- func (m *FakeApiServer) Get(arg0 schema.GroupVersionResource, arg1, arg2 string) (runtime.Object, error)
- func (m *FakeApiServer) List(arg0 schema.GroupVersionResource, arg1 string, arg2 schema.GroupVersionKind, ...) (runtime.Object, error)
- func (m *FakeApiServer) Update(arg0 schema.GroupVersionResource, arg1 string, arg2 runtime.Object) (runtime.Object, error)
- type FakeApiServerMockRecorder
- func (mr *FakeApiServerMockRecorder) Create(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) Get(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) List(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) Update(arg0, arg1, arg2 interface{}) *gomock.Call
- type Reactable
- type TestApiServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContainsAll ¶
AssertContainsAll validates that all of the search strings were in the main string. Case-insensitive.
func AssertEqual ¶
AssertEqual causes a test to fail if the two values are not DeepEqual to one another.
func AssertErrorContainsAll ¶
AssertErrorContainsAll checks that all of the search strings were in the error message. Case-insensitive.
func AssertErrorsEqual ¶
AssertErrorsEqual checks that the values of the two errors match.
func AssertFalse ¶
AssertFalse causes a test to fail if the asserted statement is true.
func AssertGolden ¶
AssertGolden asserts the given test's field matches the .golden file in testdata.
func AssertGoldenContext ¶
func AssertGoldenContext(t Failable, fieldName string, actualValue []byte, context map[string]interface{})
AssertGoldenContext adds contextual info to a header of hash marks at the start of the .golden file.
func AssertGoldenJSON ¶
AssertGoldenJSON asserts the given test's field matches the .golden file in testdata after the field has been serialized to JSON.
func AssertGoldenJSONContext ¶
func AssertGoldenJSONContext(t Failable, fieldName string, object interface{}, context map[string]interface{})
AssertGoldenJSONContext is like AssertGoldenJSON but prepends contextual test information to the golden file.
func AssertJSONEqual ¶
AssertJSONEqual ensures the expexted JSON matches the actual JSON.
func AssertKeyWithValue ¶
func AssertKeyWithValue(t Failable, m map[interface{}]interface{}, key, value interface{})
AssertKeyWithValue ensures the key is present in the map and has the given value.
func AssertNotBlank ¶
AssertNotBlank is used to validate that strings are not just made of whitespace.
func AssertNotNil ¶
AssertNotNil fails the test if the value is nil.
func AssertRegexp ¶
AssertRegexp causes a test to fail if the value does not match a pattern.
func AssertRetrySucceeds ¶
func AssertRetrySucceeds(ctx context.Context, t Failable, times int, delay time.Duration, callback func() error)
AssertRetrySucceeds asserts that a Retry call succeeds at least once.
func AssertTrue ¶
AssertTrue causes a test to fail if the asserted statement is not true.
func AssertUnstructuredEqual ¶
func AssertUnstructuredEqual(t *testing.T, field string, expected interface{}, u *unstructured.Unstructured)
AssertUnstructuredEqual asserts that the actual value is equal to the value at the given path in the Unstructured object.
func Retry ¶
Retry retries the callback for as long as the context does not have an error up to `times` times. If `times` is < 0, then it will try until the context has an error. The last error is returned.
func WithFeatureFlags ¶
WithFeatureFlags returns a context that will have a fake namespace injected into the kubeClient.
func WithGomockController ¶
func WithGomockController(t *testing.T, f func(ctrl *gomock.Controller))
WithGomockController creates a gomock.Controller and invokes Finish() via defer.
Types ¶
type ApisDefaultableTest ¶
type ApisDefaultableTest struct { // Context is the context in which to run the default. Context context.Context // Input is the value that is going to be defaulted. Input apis.Defaultable // Want is the expected result of calling SetDefaults() on the object. Want apis.Defaultable }
ApisDefaultableTest is a test format for assering apis.Defaultable objects work correctly.
func (*ApisDefaultableTest) Run ¶
func (dt *ApisDefaultableTest) Run(t *testing.T)
Run executes the test.
type ApisDefaultableTestSuite ¶
type ApisDefaultableTestSuite map[string]ApisDefaultableTest
ApisDefaultableTestSuite defines a whole suite of defaultable tests that can be run. The key in the map is the name of each test.
func (ApisDefaultableTestSuite) Run ¶
func (ts ApisDefaultableTestSuite) Run(t *testing.T)
Run executes the whole suite of tests.
type ApisValidatableTest ¶
type ApisValidatableTest struct { // Context is the context in which to run the validation. Context context.Context // Input is the value that is going to be validated. Input apis.Validatable // Want is the expected result of calling SetDefaults() on the object. Want *apis.FieldError }
ApisValidatableTest is a test format for assering apis.Validatable objects work correctly.
func (*ApisValidatableTest) Run ¶
func (dt *ApisValidatableTest) Run(t *testing.T)
Run executes the test.
type ApisValidatableTestSuite ¶
type ApisValidatableTestSuite map[string]ApisValidatableTest
ApisValidatableTestSuite defines a whole suite of validatable tests that can be run. The key in the map is the name of each test.
func (ApisValidatableTestSuite) Run ¶
func (ts ApisValidatableTestSuite) Run(t *testing.T)
Run executes the whole suite of tests.
type Failable ¶
Failable is an interface for testing.T like things. We can't use testing.TB which would be preferable because they explicitly set a private field on it to prevent others from implementing it.
type FakeApiServer ¶
type FakeApiServer struct {
// contains filtered or unexported fields
}
FakeApiServer is a mock of TestApiServer interface.
func AddFakeReactor ¶
func AddFakeReactor(fake Reactable, ctrl *gomock.Controller) *FakeApiServer
Adds a gomock compatible FakeApiServer to Kubernetes client-go testing.
func NewFakeApiServer ¶
func NewFakeApiServer(ctrl *gomock.Controller) *FakeApiServer
NewFakeApiServer creates a new mock instance.
func (*FakeApiServer) Create ¶
func (m *FakeApiServer) Create(arg0 schema.GroupVersionResource, arg1 string, arg2 runtime.Object) (runtime.Object, error)
Create mocks base method.
func (*FakeApiServer) Delete ¶
func (m *FakeApiServer) Delete(arg0 schema.GroupVersionResource, arg1, arg2 string) error
Delete mocks base method.
func (*FakeApiServer) EXPECT ¶
func (m *FakeApiServer) EXPECT() *FakeApiServerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*FakeApiServer) Get ¶
func (m *FakeApiServer) Get(arg0 schema.GroupVersionResource, arg1, arg2 string) (runtime.Object, error)
Get mocks base method.
func (*FakeApiServer) List ¶
func (m *FakeApiServer) List(arg0 schema.GroupVersionResource, arg1 string, arg2 schema.GroupVersionKind, arg3 labels.Selector) (runtime.Object, error)
List mocks base method.
type FakeApiServerMockRecorder ¶
type FakeApiServerMockRecorder struct {
// contains filtered or unexported fields
}
FakeApiServerMockRecorder is the mock recorder for FakeApiServer.
func (*FakeApiServerMockRecorder) Create ¶
func (mr *FakeApiServerMockRecorder) Create(arg0, arg1, arg2 interface{}) *gomock.Call
Create indicates an expected call of Create.
func (*FakeApiServerMockRecorder) Delete ¶
func (mr *FakeApiServerMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call
Delete indicates an expected call of Delete.
func (*FakeApiServerMockRecorder) Get ¶
func (mr *FakeApiServerMockRecorder) Get(arg0, arg1, arg2 interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*FakeApiServerMockRecorder) List ¶
func (mr *FakeApiServerMockRecorder) List(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
List indicates an expected call of List.
func (*FakeApiServerMockRecorder) Update ¶
func (mr *FakeApiServerMockRecorder) Update(arg0, arg1, arg2 interface{}) *gomock.Call
Update indicates an expected call of Update.
type Reactable ¶
type Reactable interface {
AddReactor(verb, resource string, reaction testing.ReactionFunc)
}
type TestApiServer ¶
type TestApiServer interface { // Get retrieves the object by its kind, namespace and name. Get(gvr schema.GroupVersionResource, ns, name string) (runtime.Object, error) // Create adds an object in the specified namespace. Create(gvr schema.GroupVersionResource, ns string, obj runtime.Object) (runtime.Object, error) // Update updates an existing object in the specified namespace. Update(gvr schema.GroupVersionResource, ns string, obj runtime.Object) (runtime.Object, error) // List retrieves all objects of a given kind in the given namespace. List(gvr schema.GroupVersionResource, ns string, gvk schema.GroupVersionKind, labelSelector labels.Selector) (runtime.Object, error) // Delete deletes an existing object. Delete(gvr schema.GroupVersionResource, ns, name string) error }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package integration is a generated GoMock package.
|
Package integration is a generated GoMock package. |