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

Function TestNetworkRemoveForce

cli/command/network/remove_test.go:24–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22func (notFoundErr) NotFound() {}
23
24func TestNetworkRemoveForce(t *testing.T) {
25 tests := []struct {
26 doc string
27 args []string
28 expectedErr string
29 }{
30 {
31 doc: "existing network",
32 args: []string{"existing-network"},
33 },
34 {
35 doc: "existing network (forced)",
36 args: []string{"--force", "existing-network"},
37 },
38 {
39 doc: "non-existing network",
40 args: []string{"no-such-network"},
41 expectedErr: "no such network: no-such-network",
42 },
43 {
44 doc: "non-existing network (forced)",
45 args: []string{"--force", "no-such-network"},
46 },
47 {
48 doc: "in-use network",
49 args: []string{"in-use-network"},
50 expectedErr: "network is in use",
51 },
52 {
53 doc: "in-use network (forced)",
54 args: []string{"--force", "in-use-network"},
55 expectedErr: "network is in use",
56 },
57 {
58 doc: "multiple networks",
59 args: []string{"existing-network", "no-such-network"},
60 expectedErr: "no such network: no-such-network",
61 },
62 {
63 doc: "multiple networks (forced)",
64 args: []string{"--force", "existing-network", "no-such-network"},
65 },
66 {
67 doc: "multiple networks 2 (forced)",
68 args: []string{"--force", "existing-network", "no-such-network", "in-use-network"},
69 expectedErr: "network is in use",
70 },
71 }
72
73 for _, tc := range tests {
74 t.Run(tc.doc, func(t *testing.T) {
75 fakeCli := test.NewFakeCli(&fakeClient{
76 networkRemoveFunc: func(ctx context.Context, networkID string) error {
77 switch networkID {
78 case "no-such-network":
79 return notFoundErr{errors.New("no such network: no-such-network")}
80 case "in-use-network":
81 return forBiddenErr{errors.New("network is in use")}

Callers

nothing calls this directly

Calls 7

ErrBufferMethod · 0.95
SetArgsMethod · 0.80
ContainsMethod · 0.80
newRemoveCommandFunction · 0.70
StringMethod · 0.65
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…