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

Function TestNetworkConnectErrors

cli/command/network/connect_test.go:18–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestNetworkConnectErrors(t *testing.T) {
19 testCases := []struct {
20 args []string
21 networkConnectFunc func(ctx context.Context, networkID string, options client.NetworkConnectOptions) (client.NetworkConnectResult, error)
22 expectedError string
23 }{
24 {
25 expectedError: "requires 2 arguments",
26 },
27 {
28 args: []string{"toto", "titi"},
29 networkConnectFunc: func(ctx context.Context, networkID string, options client.NetworkConnectOptions) (client.NetworkConnectResult, error) {
30 return client.NetworkConnectResult{}, errors.New("error connecting network")
31 },
32 expectedError: "error connecting network",
33 },
34 }
35
36 for _, tc := range testCases {
37 cmd := newConnectCommand(
38 test.NewFakeCli(&fakeClient{
39 networkConnectFunc: tc.networkConnectFunc,
40 }),
41 )
42 cmd.SetArgs(tc.args)
43 cmd.SetOut(io.Discard)
44 cmd.SetErr(io.Discard)
45 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
46 }
47}
48
49func TestNetworkConnectWithFlags(t *testing.T) {
50 expectedConfig := &network.EndpointSettings{

Callers

nothing calls this directly

Calls 4

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