Skip to content

Commit

Permalink
add parseargs test
Browse files Browse the repository at this point in the history
  • Loading branch information
elsesiy committed Aug 13, 2024
1 parent 5d4868f commit 3d4d32b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/cmd/view-secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ var (
secretEmpty = SecretData{}
)

func TestParseArgs(t *testing.T) {
opts := CommandOpts{}
tests := map[string]struct {
opts CommandOpts
args []string
wantOpts CommandOpts
}{
"one arg": {opts, []string{"test"}, CommandOpts{secretName: "test"}},
"two args": {opts, []string{"test", "key"}, CommandOpts{secretName: "test", secretKey: "key"}},
}

for name, test := range tests {
t.Run(name, func(t *testing.T) {
t.Parallel()

test.opts.ParseArgs(test.args)
got := test.opts
if got != test.wantOpts {
t.Errorf("got %v, want %v", got, test.wantOpts)
}
})
}
}

func TestProcessSecret(t *testing.T) {
tests := map[string]struct {
secretData SecretData
Expand Down

0 comments on commit 3d4d32b

Please sign in to comment.