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

Function TestPluginContextWrite

cli/command/plugin/formatter_test.go:72–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestPluginContextWrite(t *testing.T) {
73 tests := []struct {
74 doc string
75 context formatter.Context
76 expected string
77 }{
78 {
79 doc: "invalid function",
80 context: formatter.Context{Format: "{{InvalidFunction}}"},
81 expected: `template parsing error: template: :1: function "InvalidFunction" not defined`,
82 },
83 {
84 doc: "nil template",
85 context: formatter.Context{Format: "{{nil}}"},
86 expected: `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
87 },
88 {
89 doc: "table format",
90 context: formatter.Context{Format: newFormat("table", false)},
91 expected: `ID NAME DESCRIPTION ENABLED
92pluginID1 foobar_baz description 1 true
93pluginID2 foobar_bar description 2 false
94`,
95 },
96 {
97 doc: "table format, quiet",
98 context: formatter.Context{Format: newFormat("table", true)},
99 expected: `pluginID1
100pluginID2
101`,
102 },
103 {
104 doc: "table format name col",
105 context: formatter.Context{Format: newFormat("table {{.Name}}", false)},
106 expected: `NAME
107foobar_baz
108foobar_bar
109`,
110 },
111 {
112 doc: "table format name col, quiet",
113 context: formatter.Context{Format: newFormat("table {{.Name}}", true)},
114 expected: `NAME
115foobar_baz
116foobar_bar
117`,
118 },
119 {
120 doc: "raw format",
121 context: formatter.Context{Format: newFormat("raw", false)},
122 expected: `plugin_id: pluginID1
123name: foobar_baz
124description: description 1
125enabled: true
126
127plugin_id: pluginID2
128name: foobar_bar
129description: description 2

Callers

nothing calls this directly

Calls 4

newFormatFunction · 0.70
formatWriteFunction · 0.70
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…