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

Function TestCheckpointContextFormatWrite

cli/command/checkpoint/formatter_test.go:12–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestCheckpointContextFormatWrite(t *testing.T) {
13 cases := []struct {
14 context formatter.Context
15 expected string
16 }{
17 {
18 formatter.Context{Format: newFormat(defaultCheckpointFormat)},
19 `CHECKPOINT NAME
20checkpoint-1
21checkpoint-2
22checkpoint-3
23`,
24 },
25 {
26 formatter.Context{Format: newFormat("{{.Name}}")},
27 `checkpoint-1
28checkpoint-2
29checkpoint-3
30`,
31 },
32 {
33 formatter.Context{Format: newFormat("{{.Name}}:")},
34 `checkpoint-1:
35checkpoint-2:
36checkpoint-3:
37`,
38 },
39 }
40
41 for _, testcase := range cases {
42 out := bytes.NewBufferString("")
43 testcase.context.Output = out
44 err := formatWrite(testcase.context, []checkpoint.Summary{
45 {Name: "checkpoint-1"},
46 {Name: "checkpoint-2"},
47 {Name: "checkpoint-3"},
48 })
49 assert.NilError(t, err)
50 assert.Equal(t, out.String(), testcase.expected)
51 }
52}

Callers

nothing calls this directly

Calls 3

newFormatFunction · 0.70
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…