refactor: move base_url to config env

This commit is contained in:
debugtalk
2022-05-24 22:23:02 +08:00
parent 717b08c81c
commit ae36c8fd9a
20 changed files with 55 additions and 29 deletions

View File

@@ -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 {