mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-19 23:30:09 +08:00
change: move assertions to builtin
This commit is contained in:
17
response.go
17
response.go
@@ -8,20 +8,9 @@ import (
|
||||
|
||||
"github.com/imroc/req"
|
||||
"github.com/jmespath/go-jmespath"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var assertFunctionsMap = map[string]func(t assert.TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool{
|
||||
"equals": assert.EqualValues,
|
||||
"equal": assert.EqualValues, // alias for equals
|
||||
"greater_than": assert.Greater,
|
||||
"less_than": assert.Less,
|
||||
"greater_or_equals": assert.GreaterOrEqual,
|
||||
"less_or_equals": assert.LessOrEqual,
|
||||
"not_equal": assert.NotEqual,
|
||||
"contains": assert.Contains,
|
||||
"regex_match": assert.Regexp,
|
||||
}
|
||||
"github.com/httprunner/httpboomer/builtin"
|
||||
)
|
||||
|
||||
func NewResponseObject(t *testing.T, resp *req.Resp) *ResponseObject {
|
||||
// prepare response headers
|
||||
@@ -111,7 +100,7 @@ func (v *ResponseObject) Validate(validators []TValidator, variablesMapping map[
|
||||
|
||||
// get assert method
|
||||
assertMethod := validator.Assert
|
||||
assertFunc := assertFunctionsMap[assertMethod]
|
||||
assertFunc := builtin.Assertions[assertMethod]
|
||||
|
||||
// parse expected value
|
||||
expectValue := parseData(validator.Expect, variablesMapping)
|
||||
|
||||
Reference in New Issue
Block a user