merge main

This commit is contained in:
debugtalk
2022-03-04 17:46:04 +08:00
15 changed files with 395 additions and 17 deletions

View File

@@ -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,