mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 11:29:48 +08:00
fix: change Validators type, check json body format
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user