(t *testing.T)
| 22 | func (notFoundErr) NotFound() {} |
| 23 | |
| 24 | func 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")} |
nothing calls this directly
no test coverage detected
searching dependent graphs…