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

Function TestSwarmJoin

cli/command/swarm/join_test.go:67–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestSwarmJoin(t *testing.T) {
68 testCases := []struct {
69 name string
70 infoFunc func() (system.Info, error)
71 expected string
72 }{
73 {
74 name: "join-as-manager",
75 infoFunc: func() (system.Info, error) {
76 return system.Info{
77 Swarm: swarm.Info{
78 ControlAvailable: true,
79 },
80 }, nil
81 },
82 expected: "This node joined a swarm as a manager.",
83 },
84 {
85 name: "join-as-worker",
86 infoFunc: func() (system.Info, error) {
87 return system.Info{
88 Swarm: swarm.Info{
89 ControlAvailable: false,
90 },
91 }, nil
92 },
93 expected: "This node joined a swarm as a worker.",
94 },
95 }
96 for _, tc := range testCases {
97 t.Run(tc.name, func(t *testing.T) {
98 cli := test.NewFakeCli(&fakeClient{
99 infoFunc: tc.infoFunc,
100 })
101 cmd := newJoinCommand(cli)
102 cmd.SetArgs([]string{"remote"})
103 assert.NilError(t, cmd.Execute())
104 assert.Check(t, is.Equal(strings.TrimSpace(cli.OutBuffer().String()), tc.expected))
105 })
106 }
107}

Callers

nothing calls this directly

Calls 4

OutBufferMethod · 0.95
newJoinCommandFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…