Documentation
¶
Index ¶
- Constants
- Variables
- type Action
- func AssertAll(a ...Action) Action
- func AssertAny(a ...Action) Action
- func AssertEquals(value any) Action
- func AssertExists() Action
- func AssertGt[T constraints.Integer](value T) Action
- func AssertGte[T constraints.Integer](value T) Action
- func AssertIn[T any](values ...T) Action
- func AssertKeys(keys ...string) Action
- func AssertLen[T constraints.Integer](l T) Action
- func AssertLt[T constraints.Integer](value T) Action
- func AssertLte[T constraints.Integer](value T) Action
- func AssertNotEquals(value any) Action
- func AssertNotExists() Action
- func AssertNotIn[T any](values ...T) Action
- func AssertRegex(pattern *regexp.Regexp, count ...int) Action
- func Unmarshal(into any) Action
- func UnmarshalObjectKeys(keys KV) Action
- type KV
- type Number
- type Support
Constants ¶
const ( // ContextKeyUnmarshalActionValue is a context key for the unmarshal action value. ContextKeyUnmarshalActionValue contextKey = iota )
Variables ¶
var ( // ErrUnmarshal when unmarshalling the response ErrUnmarshal = errors.New("unmarshal error") // ErrActionNotApplied when action is not applied ErrActionNotApplied = errors.New("action not applied") // ErrAction when action is not applied ErrAction = errors.New("action") )
var ( ErrActionAssertEquals = newErrAction("AssertEquals") ErrActionAssertExists = newErrAction("AssertExists") ErrActionAssertIn = newErrAction("AssertIn") ErrActionAssertKeys = newErrAction("AssertKeys") ErrActionAssertLen = newErrAction("AssertLen") ErrActionAssertNotEquals = newErrAction("AssertNotEquals") ErrActionAssertNotExists = newErrAction("AssertNotExists") ErrActionAssertNotIn = newErrAction("AssertNotIn") ErrActionAssertGt = newErrAction("AssertGt") ErrActionAssertGte = newErrAction("AssertGte") ErrActionAssertLt = newErrAction("AssertLt") ErrActionAssertLte = newErrAction("AssertLte") ErrActionAssertAll = newErrAction("AssertAll") ErrActionAssertAny = newErrAction("AssertAny") ErrActionAssertRegex = newErrAction("AssertRegex") ErrActionUnmarshal = newErrAction("Unmarshal") ErrActionUnmarshalObjectKeys = newErrAction("UnmarshalObjectKeys") )
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface {
Run(t require.TestingT, ctx context.Context, value any, raw json.RawMessage, err error) error
Value(t require.TestingT) (any, bool)
Supports(support Support) bool
BaseError() error
}
Action is an action that can be performed on the response. It has currently 2 meanings: Assertion and Unmarshal. TODO: add path or id to run so we can print better error messages?
func AssertEquals ¶
AssertEquals asserts that given value is equal to the value in the response
func AssertExists ¶
func AssertExists() Action
AssertExists asserts that the value exists in the response based on given argument
func AssertGt ¶
func AssertGt[T constraints.Integer](value T) Action
AssertGt asserts that given value is greater than the value in the response
func AssertGte ¶
func AssertGte[T constraints.Integer](value T) Action
AssertGte asserts that given value is greater than or equal to the value in the response
func AssertKeys ¶
AssertKeys asserts that given map has the given keys
func AssertLen ¶
func AssertLen[T constraints.Integer](l T) Action
AssertLen asserts that given array/object has the given length
func AssertLt ¶
func AssertLt[T constraints.Integer](value T) Action
AssertLt asserts that given value is less than the value in the response
func AssertLte ¶
func AssertLte[T constraints.Integer](value T) Action
AssertLte asserts that given value is less than or equal to the value in the response
func AssertNotEquals ¶
AssertNotEquals asserts that given value is not equal to the value in the response
func AssertNotExists ¶
func AssertNotExists() Action
AssertNotExists asserts that the value does not exist in the response based on given argument
func AssertNotIn ¶
AssertNotIn asserts that value is not in the given list of values
func AssertRegex ¶
AssertRegex asserts that given value matches the regex in the response if count provided it will check for the number of matches, otherwise it will check if the value matches the regex
func UnmarshalObjectKeys ¶
UnmarshalObjectKeys action unmarshal the given json response object keys to the given values kv should be pairs of string key and addressable value
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}
Number constraint for number types