Skip to content

Commit

Permalink
Improve tests for the --dir option
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsch committed Jan 17, 2025
1 parent 228f618 commit e16105d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/commands/kvstoreentry/kvstoreentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ func TestCreateCommand(t *testing.T) {
Args: fmt.Sprintf("--store-id %s --dir %s", storeID, filepath.Join("testdata", "example")),
Stdin: []string{"y"},
API: mock.API{
InsertKVStoreKeyFn: func(_ *fastly.InsertKVStoreKeyInput) error {
return nil
InsertKVStoreKeyFn: func(i *fastly.InsertKVStoreKeyInput) error {
if i.Key == "foo.txt" {
return nil
}
return errors.New("invalid request")
},
},
WantOutput: "SUCCESS: Inserted 1 keys into KV Store",
Expand All @@ -87,8 +90,11 @@ func TestCreateCommand(t *testing.T) {
Args: fmt.Sprintf("--store-id %s --dir %s --dir-allow-hidden", storeID, filepath.Join("testdata", "example")),
Stdin: []string{"y"},
API: mock.API{
InsertKVStoreKeyFn: func(_ *fastly.InsertKVStoreKeyInput) error {
return nil
InsertKVStoreKeyFn: func(i *fastly.InsertKVStoreKeyInput) error {
if i.Key == "foo.txt" || i.Key == ".hiddenfile" {
return nil
}
return errors.New("invalid request")
},
},
WantOutput: "SUCCESS: Inserted 2 keys into KV Store",
Expand Down

0 comments on commit e16105d

Please sign in to comment.