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

Function TestTaskContextWriteJSONField

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

Source from the content-addressed store, hash-verified

88}
89
90func TestTaskContextWriteJSONField(t *testing.T) {
91 tasks := client.TaskListResult{
92 Items: []swarm.Task{
93 {ID: "taskID1"},
94 {ID: "taskID2"},
95 },
96 }
97 names := map[string]string{
98 "taskID1": "foobar_baz",
99 "taskID2": "foobar_bar",
100 }
101 out := bytes.NewBufferString("")
102 err := formatWrite(formatter.Context{Format: "{{json .ID}}", Output: out}, tasks, names, map[string]string{})
103 if err != nil {
104 t.Fatal(err)
105 }
106 for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
107 var s string
108 if err := json.Unmarshal([]byte(line), &s); err != nil {
109 t.Fatal(err)
110 }
111 assert.Check(t, is.Equal(tasks.Items[i].ID, s))
112 }
113}

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…