fix #1308: load .env file as environment variables

This commit is contained in:
debugtalk
2022-05-24 11:10:56 +08:00
parent 10653b2843
commit 4d8914672d
14 changed files with 77 additions and 13 deletions
+10
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)