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

Function TestNodeListFormat

cli/command/node/list_test.go:125–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func TestNodeListFormat(t *testing.T) {
126 cli := test.NewFakeCli(&fakeClient{
127 nodeListFunc: func() (client.NodeListResult, error) {
128 return client.NodeListResult{
129 Items: []swarm.Node{
130 *builders.Node(builders.NodeID("nodeID1"), builders.Hostname("nodeHostname1"), builders.Manager(builders.Leader())),
131 *builders.Node(builders.NodeID("nodeID2"), builders.Hostname("nodeHostname2"), builders.Manager()),
132 },
133 }, nil
134 },
135 infoFunc: func() (client.SystemInfoResult, error) {
136 return client.SystemInfoResult{
137 Info: system.Info{
138 Swarm: swarm.Info{NodeID: "nodeID1"},
139 },
140 }, nil
141 },
142 })
143 cli.SetConfigFile(&configfile.ConfigFile{
144 NodesFormat: "{{.ID}}: {{.Hostname}} {{.Status}}/{{.ManagerStatus}}",
145 })
146 cmd := newListCommand(cli)
147 assert.Check(t, cmd.Flags().Set("format", "{{.Hostname}}: {{.ManagerStatus}}"))
148 assert.NilError(t, cmd.Execute())
149 golden.Assert(t, cli.OutBuffer().String(), "node-list-format-flag.golden")
150}

Callers

nothing calls this directly

Calls 7

SetConfigFileMethod · 0.95
OutBufferMethod · 0.95
NodeMethod · 0.80
newListCommandFunction · 0.70
StringMethod · 0.65
HostnameMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…