MCPcopy
hub / github.com/github/github-mcp-server / TestAllToolsetIconsExist

Function TestAllToolsetIconsExist

pkg/github/toolset_icons_test.go:14–64  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

12// references an icon that actually exists in the embedded octicons.
13// This prevents broken icon references from being merged.
14func 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,

Callers

nothing calls this directly

Calls 5

IconsFunction · 0.92
NewInventoryFunction · 0.85
RemoteOnlyToolsetsFunction · 0.85
BuildMethod · 0.80
AvailableToolsetsMethod · 0.80

Tested by

no test coverage detected