mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
merge main
This commit is contained in:
12
response.go
12
response.go
@@ -115,8 +115,12 @@ func (v *responseObject) Extract(extractors map[string]string) map[string]interf
|
||||
return extractMapping
|
||||
}
|
||||
|
||||
func (v *responseObject) Validate(validators []Validator, variablesMapping map[string]interface{}) (err error) {
|
||||
for _, validator := range validators {
|
||||
func (v *responseObject) Validate(iValidators []interface{}, variablesMapping map[string]interface{}) (err error) {
|
||||
for _, iValidator := range iValidators {
|
||||
validator, ok := iValidator.(Validator)
|
||||
if !ok {
|
||||
return errors.New("validator type error")
|
||||
}
|
||||
// parse check value
|
||||
checkItem := validator.Check
|
||||
var checkValue interface{}
|
||||
@@ -161,6 +165,7 @@ func (v *responseObject) Validate(validators []Validator, variablesMapping map[s
|
||||
}
|
||||
v.validationResults = append(v.validationResults, validResult)
|
||||
log.Info().
|
||||
Str("checkExpr", validator.Check).
|
||||
Str("assertMethod", assertMethod).
|
||||
Interface("expectValue", expectValue).
|
||||
Interface("checkValue", checkValue).
|
||||
@@ -169,7 +174,8 @@ func (v *responseObject) Validate(validators []Validator, variablesMapping map[s
|
||||
if !result {
|
||||
v.t.Fail()
|
||||
return errors.New(fmt.Sprintf(
|
||||
"do assertion failed, assertMethod: %v, checkValue: %v, expectValue: %v",
|
||||
"do assertion failed, checkExpr: %v, assertMethod: %v, checkValue: %v, expectValue: %v",
|
||||
validator.Check,
|
||||
assertMethod,
|
||||
checkValue,
|
||||
expectValue,
|
||||
|
||||
Reference in New Issue
Block a user