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

Function TestContainerListFormatTemplateWithArg

cli/command/container/list_test.go:214–232  ·  view source on GitHub ↗

Test for GitHub issue docker/docker#30291

(t *testing.T)

Source from the content-addressed store, hash-verified

212
213// Test for GitHub issue docker/docker#30291
214func TestContainerListFormatTemplateWithArg(t *testing.T) {
215 cli := test.NewFakeCli(&fakeClient{
216 containerListFunc: func(_ client.ContainerListOptions) (client.ContainerListResult, error) {
217 return client.ContainerListResult{
218 Items: []container.Summary{
219 *builders.Container("c1", builders.WithLabel("some.label", "value")),
220 *builders.Container("c2", builders.WithName("foo/bar"), builders.WithLabel("foo", "bar")),
221 },
222 }, nil
223 },
224 })
225 cmd := newListCommand(cli)
226 cmd.SetArgs([]string{})
227 cmd.SetOut(io.Discard)
228 cmd.SetErr(io.Discard)
229 assert.Check(t, cmd.Flags().Set("format", `{{.Names}} {{.Label "some.label"}}`))
230 assert.NilError(t, cmd.Execute())
231 golden.Assert(t, cli.OutBuffer().String(), "container-list-format-with-arg.golden")
232}
233
234func TestContainerListFormatSizeSetsOption(t *testing.T) {
235 tests := []struct {

Callers

nothing calls this directly

Calls 8

OutBufferMethod · 0.95
ContainerMethod · 0.80
SetArgsMethod · 0.80
newListCommandFunction · 0.70
StringMethod · 0.65
SetOutMethod · 0.45
SetErrMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…