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

Function TestNetworkDisconnectErrors

cli/command/network/disconnect_test.go:14–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestNetworkDisconnectErrors(t *testing.T) {
15 testCases := []struct {
16 args []string
17 networkDisconnectFunc func(ctx context.Context, networkID string, options client.NetworkDisconnectOptions) (client.NetworkDisconnectResult, error)
18 expectedError string
19 }{
20 {
21 expectedError: "requires 2 arguments",
22 },
23 {
24 args: []string{"toto", "titi"},
25 networkDisconnectFunc: func(ctx context.Context, networkID string, options client.NetworkDisconnectOptions) (client.NetworkDisconnectResult, error) {
26 return client.NetworkDisconnectResult{}, errors.New("error disconnecting network")
27 },
28 expectedError: "error disconnecting network",
29 },
30 }
31
32 for _, tc := range testCases {
33 cmd := newDisconnectCommand(
34 test.NewFakeCli(&fakeClient{
35 networkDisconnectFunc: tc.networkDisconnectFunc,
36 }),
37 )
38 cmd.SetArgs(tc.args)
39 cmd.SetOut(io.Discard)
40 cmd.SetErr(io.Discard)
41 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
42 }
43}

Callers

nothing calls this directly

Calls 4

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