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

Function TestFormat

cli/command/formatter/formatter_test.go:14–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestFormat(t *testing.T) {
15 tests := []struct {
16 doc string
17 f Format
18 isJSON bool
19 isTable bool
20 template string
21 }{
22 {
23 doc: "json format",
24 f: "json",
25 isJSON: true,
26 isTable: false,
27 template: JSONFormat,
28 },
29 {
30 doc: "empty table format (no template)",
31 f: "table",
32 isJSON: false,
33 isTable: true,
34 template: "",
35 },
36 {
37 doc: "table with escaped tabs",
38 f: "table {{.Field}}\\t{{.Field2}}",
39 isJSON: false,
40 isTable: true,
41 template: "{{.Field}}\t{{.Field2}}",
42 },
43 {
44 doc: "table with raw string",
45 f: `table {{.Field}}\t{{.Field2}}`,
46 isJSON: false,
47 isTable: true,
48 template: "{{.Field}}\t{{.Field2}}",
49 },
50 {
51 doc: "other format",
52 f: "other",
53 isJSON: false,
54 isTable: false,
55 template: "other",
56 },
57 {
58 doc: "other with spaces",
59 f: " other ",
60 isJSON: false,
61 isTable: false,
62 template: "other",
63 },
64 {
65 doc: "other with newline preserved",
66 f: " other\n ",
67 isJSON: false,
68 isTable: false,
69 template: "other\n",
70 },
71 }

Callers

nothing calls this directly

Calls 3

IsJSONMethod · 0.80
IsTableMethod · 0.80
templateStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…