mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-05 07:49:37 +08:00
feat: parse checkItem before searchField
This commit is contained in:
@@ -9,6 +9,30 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSearchJmespath(t *testing.T) {
|
||||
testText := `{"a": {"b": "foo"}, "c": "bar", "d": {"e": [{"f": "foo"}, {"f": "bar"}]}}`
|
||||
testData := []struct {
|
||||
raw string
|
||||
expected string
|
||||
}{
|
||||
{"body.a.b", "foo"},
|
||||
{"body.c", "bar"},
|
||||
{"body.d.e[0].f", "foo"},
|
||||
{"body.d.e[1].f", "bar"},
|
||||
}
|
||||
resp := http.Response{}
|
||||
resp.Body = io.NopCloser(strings.NewReader(testText))
|
||||
respObj, err := newResponseObject(t, newParser(), &resp)
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
for _, data := range testData {
|
||||
if !assert.Equal(t, data.expected, respObj.searchJmespath(data.raw)) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchRegexp(t *testing.T) {
|
||||
testText := `hrp aims to be a one-stop solution for HTTP(S) testing, covering API testing, load testing and digital experience monitoring (DEM).`
|
||||
testData := []struct {
|
||||
|
||||
Reference in New Issue
Block a user