Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit d008233

Browse files
committed
Add tests for using custom env file
1 parent fc7c6cb commit d008233

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

internals/secrethub/run_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,27 @@ func TestRunCommand_environment(t *testing.T) {
659659
},
660660
err: ErrReadDefaultEnvFile(defaultEnvFile, os.ErrPermission),
661661
},
662+
"custom env file does not exist": {
663+
command: RunCommand{
664+
envFile: "foo.env",
665+
readFile: func(filename string) ([]byte, error) {
666+
if filename == "foo.env" {
667+
return nil, &os.PathError{Op: "open", Path: "foo.env", Err: os.ErrNotExist}
668+
}
669+
return nil, nil
670+
},
671+
},
672+
err: ErrCannotReadFile("foo.env", &os.PathError{Op: "open", Path: "foo.env", Err: os.ErrNotExist}),
673+
},
674+
"custom env file success": {
675+
command: RunCommand{
676+
envFile: "foo.env",
677+
templateVersion: "2",
678+
osStat: osStatFuncFromMap(map[string]error{"foo.env": nil}),
679+
readFile: readFileFuncFromMap(map[string]string{"foo.env": "TEST=test"}),
680+
},
681+
expectedEnv: []string{"TEST=test"},
682+
},
662683
"env file secret does not exist": {
663684
command: RunCommand{
664685
command: []string{"echo", "test"},

0 commit comments

Comments
 (0)