fix #1308: load .env file as environment variables

This commit is contained in:
debugtalk
2022-05-23 21:16:23 +08:00
parent 7c85630c3d
commit f317fa05c0
14 changed files with 77 additions and 13 deletions

View File

@@ -80,6 +80,16 @@ func (path *TestCasePath) ToTestCase() (*TestCase, error) {
return nil, errors.Wrap(err, "failed to get project root dir")
}
// 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)
if err != nil {
return nil, errors.Wrap(err, "failed to load .env file")
}
}
for _, step := range tc.TestSteps {
if step.API != nil {
apiPath, ok := step.API.(string)