(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…