bugfix: deal with empty base_url

This commit is contained in:
buyuxiang
2022-05-30 20:56:11 +08:00
parent 8ed2f84cf5
commit 4f855de419
2 changed files with 6 additions and 3 deletions

View File

@@ -118,7 +118,7 @@ func TestMakeTestCaseFromHAR(t *testing.T) {
if !assert.Equal(t, map[string]interface{}{"foo1": "HDnY8", "foo2": 12.3}, tCase.TestSteps[1].Request.Body) {
t.Fatal()
}
if !assert.Equal(t, "foo1=HDnY8&foo2=12.3", tCase.TestSteps[2].Request.Body) {
if !assert.Equal(t, map[string]string{"foo1": "HDnY8", "foo2": "12.3"}, tCase.TestSteps[2].Request.Body) {
t.Fatal()
}
@@ -264,7 +264,7 @@ func TestMakeRequestDataParams(t *testing.T) {
t.Fatal()
}
if !assert.Equal(t, "a=1&b=2", step.Request.Body) {
if !assert.Equal(t, map[string]string{"a": "1", "b": "2"}, step.Request.Body) {
t.Fatal()
}
}

View File

@@ -145,7 +145,10 @@ func (r *requestBuilder) prepareUrlParams(stepVariables map[string]interface{})
log.Error().Err(err).Msg("parse request url failed")
return err
}
baseURL := stepVariables["base_url"].(string)
var baseURL string
if stepVariables["base_url"] != nil {
baseURL = stepVariables["base_url"].(string)
}
rawUrl := buildURL(baseURL, convertString(requestUrl))
// prepare request params