fix: change Validators type, check json body format

This commit is contained in:
buyuxiang
2022-03-01 18:05:13 +08:00
parent c144d14a4e
commit b04a57eb09
7 changed files with 40 additions and 26 deletions

View File

@@ -145,7 +145,7 @@ func (h *har) prepareTestStep(entry *Entry) (*hrp.TStep, error) {
step := &tStep{
TStep: hrp.TStep{
Request: &hrp.Request{},
Validators: make([]hrp.Validator, 0),
Validators: make([]interface{}, 0),
},
}
if err := step.makeRequestMethod(entry); err != nil {

View File

@@ -1,6 +1,7 @@
package har2case
import (
"github.com/httprunner/hrp"
"testing"
"github.com/stretchr/testify/assert"
@@ -98,13 +99,13 @@ func TestMakeTestCase(t *testing.T) {
}
// make validators
if !assert.Equal(t, "status_code", tCase.TestSteps[0].Validators[0].Check) {
if validator, ok := tCase.TestSteps[0].Validators[0].(hrp.Validator); !ok || !assert.Equal(t, "status_code", validator.Check) {
t.Fail()
}
if !assert.Equal(t, "headers.\"Content-Type\"", tCase.TestSteps[0].Validators[1].Check) {
if validator, ok := tCase.TestSteps[0].Validators[1].(hrp.Validator); !ok || !assert.Equal(t, "headers.\"Content-Type\"", validator.Check) {
t.Fail()
}
if !assert.Equal(t, "body.url", tCase.TestSteps[0].Validators[2].Check) {
if validator, ok := tCase.TestSteps[0].Validators[2].(hrp.Validator); !ok || !assert.Equal(t, "body.url", validator.Check) {
t.Fail()
}
}