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

Function TestNodeContextWriteJSONField

cli/command/node/formatter_test.go:279–298  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestNodeContextWriteJSONField(t *testing.T) {
280 nodes := client.NodeListResult{
281 Items: []swarm.Node{
282 {ID: "nodeID1", Description: swarm.NodeDescription{Hostname: "foobar_baz"}},
283 {ID: "nodeID2", Description: swarm.NodeDescription{Hostname: "foobar_bar"}},
284 },
285 }
286 out := bytes.NewBufferString("")
287 err := formatWrite(formatter.Context{Format: "{{json .ID}}", Output: out}, nodes, client.SystemInfoResult{})
288 if err != nil {
289 t.Fatal(err)
290 }
291 for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
292 msg := fmt.Sprintf("Output: line %d: %s", i, line)
293 var s string
294 err := json.Unmarshal([]byte(line), &s)
295 assert.NilError(t, err, msg)
296 assert.Check(t, is.Equal(nodes.Items[i].ID, s), msg)
297 }
298}
299
300func TestNodeInspectWriteContext(t *testing.T) {
301 node := swarm.Node{

Callers

nothing calls this directly

Calls 2

formatWriteFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…