(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestVendorAndVersion(t *testing.T) { |
| 14 | // Non plugin. |
| 15 | assert.Equal(t, vendorAndVersion(&cobra.Command{Use: "test"}), "") |
| 16 | |
| 17 | // Plugins with various lengths of vendor. |
| 18 | for _, tc := range []struct { |
| 19 | vendor string |
| 20 | version string |
| 21 | expected string |
| 22 | }{ |
| 23 | {vendor: "vendor", expected: "(vendor)"}, |
| 24 | {vendor: "vendor", version: "testing", expected: "(vendor, testing)"}, |
| 25 | } { |
| 26 | t.Run(tc.vendor, func(t *testing.T) { |
| 27 | cmd := &cobra.Command{ |
| 28 | Use: "test", |
| 29 | Annotations: map[string]string{ |
| 30 | metadata.CommandAnnotationPlugin: "true", |
| 31 | metadata.CommandAnnotationPluginVendor: tc.vendor, |
| 32 | metadata.CommandAnnotationPluginVersion: tc.version, |
| 33 | }, |
| 34 | } |
| 35 | assert.Equal(t, vendorAndVersion(cmd), tc.expected) |
| 36 | }) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func TestInvalidPlugin(t *testing.T) { |
| 41 | root := &cobra.Command{Use: "root"} |
nothing calls this directly
no test coverage detected
searching dependent graphs…