fix: unittest

This commit is contained in:
debugtalk
2022-05-25 11:17:19 +08:00
parent 36fb3b22f1
commit 780a7e24e6
15 changed files with 25 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
# Release History
## v4.1.0 (2022-05-24)
## v4.1.0 (2022-05-25)
- feat: add `wiki` sub-command to open httprunner website

View File

@@ -37,4 +37,4 @@ Copyright 2017 debugtalk
* [hrp startproject](hrp_startproject.md) - create a scaffold project
* [hrp wiki](hrp_wiki.md) - visit https://httprunner.com
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -42,4 +42,4 @@ hrp boom [flags]
* [hrp](hrp.md) - Next-Generation API Testing Solution.
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -18,4 +18,4 @@ hrp convert $path... [flags]
* [hrp](hrp.md) - Next-Generation API Testing Solution.
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -24,4 +24,4 @@ hrp har2case $har_path... [flags]
* [hrp](hrp.md) - Next-Generation API Testing Solution.
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -16,4 +16,4 @@ hrp pytest $path ... [flags]
* [hrp](hrp.md) - Next-Generation API Testing Solution.
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -35,4 +35,4 @@ hrp run $path... [flags]
* [hrp](hrp.md) - Next-Generation API Testing Solution.
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -20,4 +20,4 @@ hrp startproject $project_name [flags]
* [hrp](hrp.md) - Next-Generation API Testing Solution.
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -16,4 +16,4 @@ hrp wiki [flags]
* [hrp](hrp.md) - Next-Generation API Testing Solution.
###### Auto generated by spf13/cobra on 24-May-2022
###### Auto generated by spf13/cobra on 25-May-2022

View File

@@ -1,6 +1,6 @@
{
"project_name": "demo-with-go-plugin",
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-go-plugin",
"create_time": "2022-05-24T22:23:19.739989+08:00",
"create_time": "2022-05-25T11:14:42.750876+08:00",
"hrp_version": "v4.1.0-beta"
}

View File

@@ -1,6 +1,6 @@
{
"project_name": "demo-with-py-plugin",
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-py-plugin",
"create_time": "2022-05-24T22:23:27.199105+08:00",
"create_time": "2022-05-25T11:14:52.333942+08:00",
"hrp_version": "v4.1.0-beta"
}

View File

@@ -1,6 +1,6 @@
{
"project_name": "demo-without-plugin",
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-without-plugin",
"create_time": "2022-05-24T22:23:27.955511+08:00",
"create_time": "2022-05-25T11:14:53.862348+08:00",
"hrp_version": "v4.1.0-beta"
}

View File

@@ -10,7 +10,7 @@ import (
func NewConfig(name string) *TConfig {
return &TConfig{
Name: name,
Env: make(map[string]string),
Environs: make(map[string]string),
Variables: make(map[string]interface{}),
}
}
@@ -22,7 +22,7 @@ type TConfig struct {
Verify bool `json:"verify,omitempty" yaml:"verify,omitempty"`
BaseURL string `json:"base_url,omitempty" yaml:"base_url,omitempty"` // deprecated in v4.1, moved to env
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"` // public request headers
Env map[string]string `json:"env,omitempty" yaml:"env,omitempty"` // environment variables
Environs map[string]string `json:"environs,omitempty" yaml:"environs,omitempty"` // environment variables
Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"` // global variables
Parameters map[string]interface{} `json:"parameters,omitempty" yaml:"parameters,omitempty"`
ParametersSetting *TParamsConfig `json:"parameters_setting,omitempty" yaml:"parameters_setting,omitempty"`

View File

@@ -289,18 +289,20 @@ func (r *testCaseRunner) parseConfig() error {
// merge config environment variables with base_url
// priority: env base_url > base_url
if cfg.Env != nil {
r.parsedConfig.Env = cfg.Env
if cfg.Environs != nil {
r.parsedConfig.Environs = cfg.Environs
} else {
r.parsedConfig.Env = make(map[string]string)
r.parsedConfig.Environs = make(map[string]string)
}
if value, ok := r.parsedConfig.Env["base_url"]; !ok || value == "" {
r.parsedConfig.Env["base_url"] = r.parsedConfig.BaseURL
if value, ok := r.parsedConfig.Environs["base_url"]; !ok || value == "" {
if r.parsedConfig.BaseURL != "" {
r.parsedConfig.Environs["base_url"] = r.parsedConfig.BaseURL
}
}
// merge config variables with environment variables
// priority: env > config variables
for k, v := range r.parsedConfig.Env {
for k, v := range r.parsedConfig.Environs {
r.parsedConfig.Variables[k] = v
}

View File

@@ -91,11 +91,11 @@ func (path *TestCasePath) ToTestCase() (*TestCase, error) {
// override testcase config env with variables loaded from .env file
// priority: .env file > testcase config env
if testCase.Config.Env == nil {
testCase.Config.Env = make(map[string]string)
if testCase.Config.Environs == nil {
testCase.Config.Environs = make(map[string]string)
}
for key, value := range envVars {
testCase.Config.Env[key] = value
testCase.Config.Environs[key] = value
}
}