MCPcopy Index your code
hub / github.com/github/github-mcp-server / TestStripMetaKeys

Function TestStripMetaKeys

pkg/inventory/registry_test.go:1928–1998  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1926}
1927
1928func TestStripMetaKeys(t *testing.T) {
1929 tests := []struct {
1930 name string
1931 meta map[string]any
1932 keys []string
1933 expectChange bool
1934 expectedMeta map[string]any // nil means Meta should be nil
1935 }{
1936 {
1937 name: "nil meta - no change",
1938 meta: nil,
1939 keys: mcpAppsMetaKeys,
1940 expectChange: false,
1941 },
1942 {
1943 name: "no matching keys - no change",
1944 meta: map[string]any{"description": "test", "version": "1.0"},
1945 keys: mcpAppsMetaKeys,
1946 expectChange: false,
1947 },
1948 {
1949 name: "ui key only - becomes nil",
1950 meta: map[string]any{"ui": "data"},
1951 keys: mcpAppsMetaKeys,
1952 expectChange: true,
1953 expectedMeta: nil,
1954 },
1955 {
1956 name: "ui key with other keys - ui stripped",
1957 meta: map[string]any{"ui": "data", "description": "kept"},
1958 keys: mcpAppsMetaKeys,
1959 expectChange: true,
1960 expectedMeta: map[string]any{"description": "kept"},
1961 },
1962 {
1963 name: "ui is nil value - ui stripped",
1964 meta: map[string]any{"ui": nil, "description": "kept"},
1965 keys: mcpAppsMetaKeys,
1966 expectChange: true,
1967 expectedMeta: map[string]any{"description": "kept"},
1968 },
1969 {
1970 name: "empty keys list - no change",
1971 meta: map[string]any{"ui": "data"},
1972 keys: []string{},
1973 expectChange: false,
1974 },
1975 }
1976
1977 for _, tt := range tests {
1978 t.Run(tt.name, func(t *testing.T) {
1979 tool := mockToolWithMeta("test", "toolset1", tt.meta)
1980 result := stripMetaKeys(tool, tt.keys)
1981
1982 if tt.expectChange {
1983 require.NotNil(t, result, "expected change but got nil")
1984 if tt.expectedMeta == nil {
1985 require.Nil(t, result.Tool.Meta, "expected Meta to be nil")

Callers

nothing calls this directly

Calls 2

mockToolWithMetaFunction · 0.85
stripMetaKeysFunction · 0.85

Tested by

no test coverage detected