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

Commit d6d8d44

Browse files
committed
Add tests for secrethub:// os environment variable replacement
1 parent 7087841 commit d6d8d44

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

internals/secrethub/run_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,46 @@ func TestRunCommand_Run(t *testing.T) {
550550
},
551551
err: ErrInvalidTemplateVar("foo@bar"),
552552
},
553+
"os env secret not found": {
554+
command: RunCommand{
555+
osEnv: func() []string {
556+
return []string{"TEST=secrethub://nonexistent/secret/path"}
557+
},
558+
command: []string{"echo", "test"},
559+
newClient: func() (secrethub.ClientInterface, error) {
560+
return fakeclient.Client{
561+
SecretService: &fakeclient.SecretService{
562+
VersionService: &fakeclient.SecretVersionService{
563+
WithDataGetter: fakeclient.WithDataGetter{
564+
Err: api.ErrSecretNotFound,
565+
},
566+
},
567+
},
568+
}, nil
569+
},
570+
},
571+
err: api.ErrSecretNotFound,
572+
},
573+
"os env secret not found ignored": {
574+
command: RunCommand{
575+
osEnv: func() []string {
576+
return []string{"TEST=secrethub://nonexistent/secret/path"}
577+
},
578+
ignoreMissingSecrets: true,
579+
command: []string{"echo", "test"},
580+
newClient: func() (secrethub.ClientInterface, error) {
581+
return fakeclient.Client{
582+
SecretService: &fakeclient.SecretService{
583+
VersionService: &fakeclient.SecretVersionService{
584+
WithDataGetter: fakeclient.WithDataGetter{
585+
Err: api.ErrSecretNotFound,
586+
},
587+
},
588+
},
589+
}, nil
590+
},
591+
},
592+
},
553593
}
554594

555595
for name, tc := range cases {

0 commit comments

Comments
 (0)