modify assertion functions and their docs

Change-Id: I12bc6425e098b62b08bd5ca2fb7a9cc0482e1910
This commit is contained in:
buyuxiang
2022-02-11 17:54:32 +08:00
parent 293551997f
commit 5c03e0d325
5 changed files with 142 additions and 58 deletions

View File

@@ -115,7 +115,10 @@ func (v *responseObject) Validate(validators []Validator, variablesMapping map[s
// get assert method
assertMethod := validator.Assert
assertFunc := builtin.Assertions[assertMethod]
assertFunc, ok := builtin.Assertions[assertMethod]
if !ok {
return errors.New(fmt.Sprintf("unexpected assertion method: %v", assertMethod))
}
// parse expected value
expectValue, err := v.parser.parseData(validator.Expect, variablesMapping)
@@ -134,7 +137,7 @@ func (v *responseObject) Validate(validators []Validator, variablesMapping map[s
}
// do assertion
result := assertFunc(v.t, expectValue, checkValue)
result := assertFunc(v.t, checkValue, expectValue)
if result {
validResult.CheckResult = "pass"
}