| 163 | } |
| 164 | |
| 165 | func TestTaskPrintWithResolution(t *testing.T) { |
| 166 | const quiet = false |
| 167 | const trunc = false |
| 168 | const noResolve = false |
| 169 | apiClient := &fakeClient{ |
| 170 | serviceInspectFunc: func(ref string, options client.ServiceInspectOptions) (client.ServiceInspectResult, error) { |
| 171 | return client.ServiceInspectResult{ |
| 172 | Service: *builders.Service(builders.ServiceName("service-name-foo")), |
| 173 | }, nil |
| 174 | }, |
| 175 | nodeInspectFunc: func(ref string) (client.NodeInspectResult, error) { |
| 176 | return client.NodeInspectResult{ |
| 177 | Node: *builders.Node(builders.NodeName("node-name-bar")), |
| 178 | }, nil |
| 179 | }, |
| 180 | } |
| 181 | cli := test.NewFakeCli(apiClient) |
| 182 | tasks := client.TaskListResult{ |
| 183 | Items: []swarm.Task{ |
| 184 | *builders.Task(builders.TaskServiceID("service-id-foo"), builders.TaskSlot(1)), |
| 185 | }, |
| 186 | } |
| 187 | err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .Name }} {{ .Node }}") |
| 188 | assert.NilError(t, err) |
| 189 | golden.Assert(t, cli.OutBuffer().String(), "task-print-with-resolution.golden") |
| 190 | } |