mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-05 15:59:33 +08:00
move convertCheckExpr to convertCompatTestCase
This commit is contained in:
15
response.go
15
response.go
@@ -185,7 +185,6 @@ func (v *responseObject) Validate(iValidators []interface{}, variablesMapping ma
|
||||
}
|
||||
|
||||
func (v *responseObject) searchJmespath(expr string) interface{} {
|
||||
expr = convertJmespath(expr)
|
||||
checkValue, err := jmespath.Search(expr, v.respObjMeta)
|
||||
if err != nil {
|
||||
log.Error().Str("expr", expr).Err(err).Msg("search jmespath failed")
|
||||
@@ -201,20 +200,6 @@ func (v *responseObject) searchJmespath(expr string) interface{} {
|
||||
return checkValue
|
||||
}
|
||||
|
||||
// convertJmespath deals with check expression including hyphen
|
||||
func convertJmespath(checkExpr string) string {
|
||||
if strings.Contains(checkExpr, textExtractorSubRegexp) {
|
||||
return checkExpr
|
||||
}
|
||||
checkItems := strings.Split(checkExpr, ".")
|
||||
for i, checkItem := range checkItems {
|
||||
if strings.Contains(checkItem, "-") && !strings.Contains(checkItem, "\"") {
|
||||
checkItems[i] = fmt.Sprintf("\"%s\"", checkItem)
|
||||
}
|
||||
}
|
||||
return strings.Join(checkItems, ".")
|
||||
}
|
||||
|
||||
func (v *responseObject) searchRegexp(expr string) interface{} {
|
||||
respMap, ok := v.respObjMeta.(map[string]interface{})
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user