(t *testing.T)
| 277 | } |
| 278 | |
| 279 | func 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 | |
| 300 | func TestNodeInspectWriteContext(t *testing.T) { |
| 301 | node := swarm.Node{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…