Documentation ¶
Overview ¶
Package testutils provides utility functions for testing. It also allows recording tests, both their input and expected output. The recorded test is then saved to a JSON file which is provided by the NOBL9_SDK_TEST_RECORD_FILE environment variable. The env variable should be an absolute path, otherwise every package will have a separate file created.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContainsErrors ¶
func AssertContainsErrors( t *testing.T, object interface{}, objErr *v1alpha.ObjectError, expectedErrorsCount int, expectedErrors ...ExpectedError, )
AssertContainsErrors asserts that the given object has: - the expected number of errors - at least one error which matches ExpectedError
ExpectedError and actual error are considered equal if they point at the same property and either: - validation.ErrorCode are equal - error messages re equal - ExpectedError.ContainsMessage is contained in actual error message
nolint: gocognit
func AssertNoError ¶
func AssertNoError(t *testing.T, object interface{}, objErr *v1alpha.ObjectError)
AssertNoError asserts that the provided v1alpha.ObjectError is nil.
func FindModuleRoot ¶ added in v0.82.0
func FindModuleRoot() string
FindModuleRoot returns the absolute path to the modules root.
Types ¶
type ExpectedError ¶
type ExpectedError struct { Prop string `json:"property"` Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` ContainsMessage string `json:"containsMessage,omitempty"` IsKeyError bool `json:"isKeyError,omitempty"` }
func PrependPropertyPath ¶
func PrependPropertyPath(errs []ExpectedError, path string) []ExpectedError