Documentation
¶
Index ¶
- Constants
- Variables
- func AssertEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})
- func AssertNotEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})
- func EqualError(err error) error
- func EqualErrorString(err string) error
- func EqualErrorType(err error) error
- func Mutate(u *unstructured.Unstructured, mutators ...Mutator) *unstructured.Unstructured
- func NewFakeRESTMapper(gvks ...schema.GroupVersionKind) meta.RESTMapper
- func ToIdentifier(t *testing.T, manifest string) object.ObjMetadata
- func Unstructured(t *testing.T, manifest string, mutators ...Mutator) *unstructured.Unstructured
- type Asserter
- type EqualMatcher
- type Mutator
- type TestFilesystem
Constants ¶
const OwningInventoryKey = "config.k8s.io/owning-inventory"
OwningInventoryKey is the annotation key indicating the inventory owning an object. This is a copy of inventory.OwningInventoryKey to avoid dependency cycle.
Variables ¶
var DefaultAsserter = NewAsserter(cmpopts.EquateErrors())
DefaultAsserter is a global Asserter with default comparison options: - EquateErrors (compare with "Is(T) bool" method)
Functions ¶
func AssertEqual ¶
AssertEqual fails the test if the actual value does not deeply equal the expected value. Prints a diff on failure.
func AssertNotEqual ¶
AssertNotEqual fails the test if the actual value deeply equals the expected value. Prints a diff on failure.
func EqualError ¶
EqualError returns an error with an Is(error)bool function that matches any error with the same type and string value as the supplied error.
Use with testutil.Equal to handle error comparisons.
func EqualErrorString ¶
EqualErrorString returns an error with an Is(error)bool function that matches any error with the same Error() as the supplied string value.
Use with testutil.Equal to handle error comparisons.
func EqualErrorType ¶
EqualErrorType returns an error with an Is(error)bool function that matches any error with the same type as the supplied error.
Use with testutil.Equal to handle error comparisons.
func Mutate ¶
func Mutate(u *unstructured.Unstructured, mutators ...Mutator) *unstructured.Unstructured
Mutate executes the specified Mutators on the specified object.
func NewFakeRESTMapper ¶
func NewFakeRESTMapper(gvks ...schema.GroupVersionKind) meta.RESTMapper
func ToIdentifier ¶
func ToIdentifier(t *testing.T, manifest string) object.ObjMetadata
ToIdentifier translates object yaml config into ObjMetadata.
func Unstructured ¶
func Unstructured(t *testing.T, manifest string, mutators ...Mutator) *unstructured.Unstructured
Unstructured translates the passed object config string into an object in Unstructured format. The mutators modify the config yaml before returning the object.
Types ¶
type Asserter ¶
Asserter provides a set of assertion methods that use a shared set of comparison options.
func NewAsserter ¶
Returns a new Asserter with the specified options.
func (*Asserter) Equal ¶
Equal fails the test if the actual value does not deeply equal the expected value. Prints a diff on failure.
func (*Asserter) EqualMatcher ¶
func (a *Asserter) EqualMatcher(expected interface{}) *EqualMatcher
EqualMatcher returns a new EqualMatcher with the Asserter's options and the specified expected value.
type EqualMatcher ¶
type EqualMatcher struct {
Expected interface{}
Options cmp.Options
// contains filtered or unexported fields
}
func Equal ¶
func Equal(expected interface{}) *EqualMatcher
Equal returns a matcher for use with Gomega that uses go-cmp's cmp.Equal to compare and cmp.Diff to show the difference, if there is one.
Example Usage: Expect(receivedEvents).To(testutil.Equal(expectedEvents))
func (*EqualMatcher) FailureMessage ¶
func (cm *EqualMatcher) FailureMessage(actual interface{}) string
func (*EqualMatcher) Match ¶
func (cm *EqualMatcher) Match(actual interface{}) (bool, error)
func (*EqualMatcher) NegatedFailureMessage ¶
func (cm *EqualMatcher) NegatedFailureMessage(actual interface{}) string
type Mutator ¶
type Mutator interface {
Mutate(u *unstructured.Unstructured)
}
Mutator inteface defines a function to update an object while translating it unto Unstructured format from yaml config.
func AddOwningInv ¶
AddOwningInv returns a Mutator which adds the passed inv string as the owning inventory annotation.
type TestFilesystem ¶
type TestFilesystem struct {
// contains filtered or unexported fields
}
TestFilesystem creates directories and files for testing
func Setup ¶
func Setup(t *testing.T, dirs ...string) TestFilesystem
Setupd creates directories in the test filesystem, returning the TestFilesystem.
func (TestFilesystem) GetRootDir ¶
func (tf TestFilesystem) GetRootDir() string
GetRootDir returns the path to the root of the test filesystem.