Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Array = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "be array" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0].Type() == types.Array, nil }, }
ARRAY asserts that value is a array type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
var Binary = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "be binary" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0].Type() == types.Binary, nil }, }
BINARY asserts that value is a binary type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
var DateTime = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "be datetime" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0].Type() == types.DateTime, nil }, }
DATETIME asserts that value is a datetime type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
var Empty = base.Assertion{ DefaultMessage: func(_ []core.Value) string { return "be empty" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { size, err := collections.Length(ctx, args[0]) if err != nil { return false, err } return values.ToInt(size) == 0, nil }, }
EMPTY asserts that the target does not contain any values. @param {Measurable | Binary | Object | Any[] | String} actual - Value to test. @param {String} [message] - Message to display on error.
var Equal = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s %s", base.EqualOp, base.FormatValue(args[1])) }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return base.EqualOp.Compare(args) }, }
EQUAL asserts equality of actual and expected values. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.
var Fail = base.Assertion{ DefaultMessage: func(_ []core.Value) string { return "not fail" }, MinArgs: 0, MaxArgs: 1, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return false, nil }, }
FAIL returns an error. @param {String} [message] - Message to display on error.
var False = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s", base.FormatValue(values.False)) }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0] == values.False, nil }, }
FALSE asserts that value is false. @param {Any}actual - Value to test. @param {String} [message] - Message to display on error.
var Float = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "be float" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0].Type() == types.Float, nil }, }
FLOAT asserts that value is a float type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
var Gt = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s %s", base.GreaterOp, base.FormatValue(args[1])) }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return base.GreaterOp.Compare(args) }, }
GT asserts that an actual value is greater than an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.
var Gte = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s %s", base.GreaterOrEqualOp, base.FormatValue(args[1])) }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return base.GreaterOrEqualOp.Compare(args) }, }
GTE asserts that an actual value is greater than or equal to an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.
var Include = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("include %s", base.FormatValue(args[1])) }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { haystack := args[0] needle := args[1] out, err := collections.Includes(ctx, haystack, needle) if err != nil { return false, err } return out.Compare(values.True) == 0, nil }, }
INCLUDE asserts that haystack includes needle. @param {String | Array | Object | Iterable} actual - Haystack value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.
var Int = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "be int" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0].Type() == types.Int, nil }, }
INT asserts that value is a int type. @param {Any} actual - Actual value. @param {String} [message] - Message to display on error.
var Len = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("has size %s", args[1]) }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { col := args[0] size := args[1] out, err := collections.Length(ctx, col) if err != nil { return false, err } return out.Compare(size) == 0, nil }, }
LEN asserts that a measurable value has a length or size with the expected value. @param {Measurable} actual - Measurable value. @param {Int} length - Target length. @param {String} [message] - Message to display on error.
var Lt = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s %s", base.LessOp, base.FormatValue(args[1])) }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return base.LessOp.Compare(args) }, }
LT asserts that an actual value is lesser than an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.
var Lte = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s %s", base.LessOrEqualOp, base.FormatValue(args[1])) }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return base.LessOrEqualOp.Compare(args) }, }
LTE asserts that an actual value is lesser than or equal to an expected one. @param {Any} actual - Actual value. @param {Any} expected - Expected value. @param {String} [message] - Message to display on error.
var Match = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "match regular expression" }, MinArgs: 2, MaxArgs: 3, Fn: func(ctx context.Context, args []core.Value) (bool, error) { value := args[0] regexp := args[1] out, err := strings.RegexMatch(ctx, value, regexp) if err != nil { return false, err } return out.Compare(values.True) == 0, nil }, }
MATCH asserts that value matches the regular expression. @param {Any} actual - Actual value. @param {String} expression - Regular expression. @param {String} [message] - Message to display on error.
var None = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s", base.FormatValue(values.None)) }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0] == values.None, nil }, }
NONE asserts that value is none. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
var Object = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "be object" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0].Type() == types.Object, nil }, }
OBJECT asserts that value is a object type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
var String = base.Assertion{ DefaultMessage: func(args []core.Value) string { return "be string" }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0].Type() == types.String, nil }, }
STRING asserts that value is a string type. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
var True = base.Assertion{ DefaultMessage: func(args []core.Value) string { return fmt.Sprintf("be %s", base.FormatValue(values.True)) }, MinArgs: 1, MaxArgs: 2, Fn: func(ctx context.Context, args []core.Value) (bool, error) { return args[0] == values.True, nil }, }
TRUE asserts that value is true. @param {Any} actual - Value to test. @param {String} [message] - Message to display on error.
Functions ¶
Types ¶
This section is empty.