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

Commit fb71da6

Browse files
committed
Add test for template variable source precedence
1 parent 1d52605 commit fb71da6

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

internals/secrethub/run_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,29 @@ func TestRunCommand_environment(t *testing.T) {
840840
},
841841
err: ErrParsingTemplate("secrethub.env", api.ErrSecretNotFound),
842842
},
843+
"template var set by flag has precedence over var set by environment": {
844+
command: RunCommand{
845+
command: []string{"/bin/sh", "./test.sh"},
846+
readFile: readFileFuncFromMap(map[string]string{"secrethub.env": "TEST=$variable"}),
847+
osStat: osStatFuncFromMap(map[string]error{"secrethub.env": nil}),
848+
dontPromptMissingTemplateVar: true,
849+
templateVersion: "2",
850+
templateVars: map[string]string{"variable": "foo"},
851+
osEnv: []string{"SECRETHUB_VAR_VARIABLE=bar"},
852+
newClient: func() (secrethub.ClientInterface, error) {
853+
return fakeclient.Client{
854+
SecretService: &fakeclient.SecretService{
855+
VersionService: &fakeclient.SecretVersionService{
856+
WithDataGetter: fakeclient.WithDataGetter{
857+
Err: api.ErrSecretNotFound,
858+
},
859+
},
860+
},
861+
}, nil
862+
},
863+
},
864+
expectedEnv: []string{"TEST=foo", "SECRETHUB_VAR_VARIABLE=bar"},
865+
},
843866
"v1 template syntax success": {
844867
command: RunCommand{
845868
command: []string{"/bin/sh", "./test.sh"},

0 commit comments

Comments
 (0)