MCPcopy Create free account
hub / github.com/docker/cli / TestSecretRemoveErrors

Function TestSecretRemoveErrors

cli/command/secret/remove_test.go:16–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestSecretRemoveErrors(t *testing.T) {
17 testCases := []struct {
18 args []string
19 secretRemoveFunc func(context.Context, string, client.SecretRemoveOptions) (client.SecretRemoveResult, error)
20 expectedError string
21 }{
22 {
23 args: []string{},
24 expectedError: "requires at least 1 argument",
25 },
26 {
27 args: []string{"foo"},
28 secretRemoveFunc: func(_ context.Context, name string, _ client.SecretRemoveOptions) (client.SecretRemoveResult, error) {
29 return client.SecretRemoveResult{}, errors.New("error removing secret")
30 },
31 expectedError: "error removing secret",
32 },
33 }
34 for _, tc := range testCases {
35 cmd := newSecretRemoveCommand(
36 test.NewFakeCli(&fakeClient{
37 secretRemoveFunc: tc.secretRemoveFunc,
38 }),
39 )
40 cmd.SetArgs(tc.args)
41 cmd.SetOut(io.Discard)
42 cmd.SetErr(io.Discard)
43 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
44 }
45}
46
47func TestSecretRemoveWithName(t *testing.T) {
48 names := []string{"foo", "bar"}

Callers

nothing calls this directly

Calls 4

newSecretRemoveCommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…