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

Function TestTaskContextWrite

cli/command/task/formatter_test.go:17–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestTaskContextWrite(t *testing.T) {
18 cases := []struct {
19 context formatter.Context
20 expected string
21 }{
22 {
23 formatter.Context{Format: "{{InvalidFunction}}"},
24 `template parsing error: template: :1: function "InvalidFunction" not defined`,
25 },
26 {
27 formatter.Context{Format: "{{nil}}"},
28 `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
29 },
30 {
31 formatter.Context{Format: newTaskFormat("table", true)},
32 `taskID1
33taskID2
34`,
35 },
36 {
37 formatter.Context{Format: newTaskFormat("table {{.Name}}\t{{.Node}}\t{{.Ports}}", false)},
38 string(golden.Get(t, "task-context-write-table-custom.golden")),
39 },
40 {
41 formatter.Context{Format: newTaskFormat("table {{.Name}}", true)},
42 `NAME
43foobar_baz
44foobar_bar
45`,
46 },
47 {
48 formatter.Context{Format: newTaskFormat("raw", true)},
49 `id: taskID1
50id: taskID2
51`,
52 },
53 {
54 formatter.Context{Format: newTaskFormat("{{.Name}} {{.Node}}", false)},
55 `foobar_baz foo1
56foobar_bar foo2
57`,
58 },
59 }
60
61 tasks := client.TaskListResult{
62 Items: []swarm.Task{
63 {ID: "taskID1"},
64 {ID: "taskID2"},
65 },
66 }
67 names := map[string]string{
68 "taskID1": "foobar_baz",
69 "taskID2": "foobar_bar",
70 }
71 nodes := map[string]string{
72 "taskID1": "foo1",
73 "taskID2": "foo2",
74 }

Callers

nothing calls this directly

Calls 5

newTaskFormatFunction · 0.85
formatWriteFunction · 0.70
GetMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…