mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-08 07:51:25 +08:00
refactor: move base_url to config env
This commit is contained in:
@@ -83,11 +83,20 @@ func (path *TestCasePath) ToTestCase() (*TestCase, error) {
|
||||
// load .env file
|
||||
dotEnvPath := filepath.Join(projectRootDir, ".env")
|
||||
if builtin.IsFilePathExists(dotEnvPath) {
|
||||
testCase.Config.Env = make(map[string]string)
|
||||
err = builtin.LoadFile(dotEnvPath, testCase.Config.Env)
|
||||
envVars := make(map[string]string)
|
||||
err = builtin.LoadFile(dotEnvPath, envVars)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to load .env file")
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
for key, value := range envVars {
|
||||
testCase.Config.Env[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
for _, step := range tc.TestSteps {
|
||||
|
||||
Reference in New Issue
Block a user