fix: check empty upload

This commit is contained in:
buyuxiang
2022-07-12 17:06:02 +08:00
parent a76b3b399d
commit 296295a928
3 changed files with 4 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package hrp
import (
"fmt"
"github.com/jinzhu/copier"
"github.com/rs/zerolog/log"
@@ -126,7 +127,7 @@ func extendWithAPI(testStep *TStep, overriddenStep *API) {
// merge & override request
testStep.Request = overriddenStep.Request
// init upload
if testStep.Request.Upload != nil {
if len(testStep.Request.Upload) != 0 {
initUpload(testStep)
}
// merge & override variables

View File

@@ -268,7 +268,7 @@ func initUpload(step *TStep) {
}
func prepareUpload(parser *Parser, step *TStep, stepVariables map[string]interface{}) (err error) {
if step.Request.Upload == nil {
if len(step.Request.Upload) == 0 {
return
}
uploadMap, err := parser.Parse(step.Request.Upload, stepVariables)

View File

@@ -148,7 +148,7 @@ func (path *TestCasePath) ToTestCase() (*TestCase, error) {
})
} else if step.Request != nil {
// init upload
if step.Request.Upload != nil {
if len(step.Request.Upload) != 0 {
initUpload(step)
}
testCase.TestSteps = append(testCase.TestSteps, &StepRequestWithOptionalArgs{