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

Function TestInspect

cli/command/plugin/inspect_test.go:88–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestInspect(t *testing.T) {
89 testCases := []struct {
90 description string
91 args []string
92 flags map[string]string
93 golden string
94 inspectFunc func(name string) (client.PluginInspectResult, error)
95 }{
96 {
97 description: "inspect single plugin with format",
98 args: []string{"foo"},
99 flags: map[string]string{
100 "format": "{{ .Name }}",
101 },
102 golden: "plugin-inspect-single-with-format.golden",
103 inspectFunc: func(name string) (client.PluginInspectResult, error) {
104 return client.PluginInspectResult{
105 Plugin: plugin.Plugin{
106 ID: "id-foo",
107 Name: "name-foo",
108 },
109 }, nil
110 },
111 },
112 {
113 description: "inspect single plugin without format",
114 args: []string{"foo"},
115 golden: "plugin-inspect-single-without-format.golden",
116 inspectFunc: func(name string) (client.PluginInspectResult, error) {
117 return pluginFoo, nil
118 },
119 },
120 {
121 description: "inspect multiple plugins with format",
122 args: []string{"foo", "bar"},
123 flags: map[string]string{
124 "format": "{{ .Name }}",
125 },
126 golden: "plugin-inspect-multiple-with-format.golden",
127 inspectFunc: func(name string) (client.PluginInspectResult, error) {
128 switch name {
129 case "foo":
130 return client.PluginInspectResult{
131 Plugin: plugin.Plugin{
132 ID: "id-foo",
133 Name: "name-foo",
134 },
135 }, nil
136 case "bar":
137 return client.PluginInspectResult{
138 Plugin: plugin.Plugin{
139 ID: "id-bar",
140 Name: "name-bar",
141 },
142 }, nil
143 default:
144 return client.PluginInspectResult{}, fmt.Errorf("unexpected plugin name: %s", name)
145 }

Callers

nothing calls this directly

Calls 5

OutBufferMethod · 0.95
SetArgsMethod · 0.80
newInspectCommandFunction · 0.70
StringMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…