refactor: post data with body

This commit is contained in:
debugtalk
2021-10-15 21:12:22 +08:00
parent 54531339f8
commit 65712f626a
14 changed files with 27 additions and 34 deletions

View File

@@ -189,13 +189,13 @@ func (s *TStep) makeRequestBody(entry *Entry) error {
mimeType := entry.Request.PostData.MimeType
if strings.HasPrefix(mimeType, "application/json") {
// post json
var data interface{}
err := json.Unmarshal([]byte(entry.Request.PostData.Text), &data)
var body interface{}
err := json.Unmarshal([]byte(entry.Request.PostData.Text), &body)
if err != nil {
log.Printf("makeRequestBody error: %v", err)
return err
}
s.Request.Data = data
s.Request.Body = body
} else if strings.HasPrefix(mimeType, "application/x-www-form-urlencoded") {
// TODO: post form data
}

View File

@@ -87,7 +87,7 @@ func TestMakeTestCase(t *testing.T) {
}
// make request data
if !assert.Equal(t, map[string]interface{}{"foo1": "HDnY8", "foo2": 12.3}, tCase.TestSteps[1].Request.Data) {
if !assert.Equal(t, map[string]interface{}{"foo1": "HDnY8", "foo2": 12.3}, tCase.TestSteps[1].Request.Body) {
t.Fail()
}
}