MCPcopy Index your code
hub / github.com/docker/cli / TestConfigRemoveErrors

Function TestConfigRemoveErrors

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

Source from the content-addressed store, hash-verified

14)
15
16func TestConfigRemoveErrors(t *testing.T) {
17 testCases := []struct {
18 args []string
19 configRemoveFunc func(context.Context, string, client.ConfigRemoveOptions) (client.ConfigRemoveResult, error)
20 expectedError string
21 }{
22 {
23 args: []string{},
24 expectedError: "requires at least 1 argument",
25 },
26 {
27 args: []string{"foo"},
28 configRemoveFunc: func(ctx context.Context, name string, options client.ConfigRemoveOptions) (client.ConfigRemoveResult, error) {
29 return client.ConfigRemoveResult{}, errors.New("error removing config")
30 },
31 expectedError: "error removing config",
32 },
33 }
34 for _, tc := range testCases {
35 cmd := newConfigRemoveCommand(
36 test.NewFakeCli(&fakeClient{
37 configRemoveFunc: tc.configRemoveFunc,
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 TestConfigRemoveWithName(t *testing.T) {
48 names := []string{"foo", "bar"}

Callers

nothing calls this directly

Calls 4

newConfigRemoveCommandFunction · 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…