TestAllToolsetIconsExist validates that every toolset with an Icon field references an icon that actually exists in the embedded octicons. This prevents broken icon references from being merged.
(t *testing.T)
| 12 | // references an icon that actually exists in the embedded octicons. |
| 13 | // This prevents broken icon references from being merged. |
| 14 | func TestAllToolsetIconsExist(t *testing.T) { |
| 15 | // Get all available toolsets from the inventory |
| 16 | inv, err := NewInventory(stubTranslator).Build() |
| 17 | require.NoError(t, err) |
| 18 | toolsets := inv.AvailableToolsets() |
| 19 | |
| 20 | // Also test remote-only toolsets |
| 21 | remoteToolsets := RemoteOnlyToolsets() |
| 22 | |
| 23 | // Combine both lists |
| 24 | allToolsets := make([]struct { |
| 25 | name string |
| 26 | icon string |
| 27 | }, 0) |
| 28 | |
| 29 | for _, ts := range toolsets { |
| 30 | if ts.Icon != "" { |
| 31 | allToolsets = append(allToolsets, struct { |
| 32 | name string |
| 33 | icon string |
| 34 | }{name: string(ts.ID), icon: ts.Icon}) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | for _, ts := range remoteToolsets { |
| 39 | if ts.Icon != "" { |
| 40 | allToolsets = append(allToolsets, struct { |
| 41 | name string |
| 42 | icon string |
| 43 | }{name: string(ts.ID), icon: ts.Icon}) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | require.NotEmpty(t, allToolsets, "expected at least one toolset with an icon") |
| 48 | |
| 49 | for _, ts := range allToolsets { |
| 50 | t.Run(ts.name, func(t *testing.T) { |
| 51 | // Check that icons return valid data URIs (not empty) |
| 52 | icons := octicons.Icons(ts.icon) |
| 53 | require.NotNil(t, icons, "toolset %s references icon %q which does not exist", ts.name, ts.icon) |
| 54 | assert.Len(t, icons, 2, "expected light and dark icon variants for toolset %s", ts.name) |
| 55 | |
| 56 | // Verify both variants have valid data URIs |
| 57 | for _, icon := range icons { |
| 58 | assert.NotEmpty(t, icon.Source, "icon source should not be empty for toolset %s", ts.name) |
| 59 | assert.Contains(t, icon.Source, "data:image/png;base64,", |
| 60 | "icon %s for toolset %s should be a valid data URI", ts.icon, ts.name) |
| 61 | } |
| 62 | }) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | // TestToolsetMetadataHasIcons ensures all toolsets have icons defined. |
| 67 | // This is a policy test - if you want to allow toolsets without icons, |
nothing calls this directly
no test coverage detected