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

Function TestFeatureFlagDisable

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

Source from the content-addressed store, hash-verified

1090}
1091
1092func TestFeatureFlagDisable(t *testing.T) {
1093 tools := []ServerTool{
1094 mockTool("always_available", "toolset1", true),
1095 mockToolWithFlags("disabled_by_flag", "toolset1", true, "", "kill_switch"),
1096 }
1097
1098 // Without feature checker, tool with FeatureFlagDisable should be included (flag is false)
1099 reg := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{"all"}))
1100 available := reg.AvailableTools(context.Background())
1101 if len(available) != 2 {
1102 t.Fatalf("Expected 2 tools without feature checker, got %d", len(available))
1103 }
1104
1105 // With feature checker returning true for "kill_switch", tool should be excluded
1106 checkerTrue := func(_ context.Context, flag string) (bool, error) {
1107 return flag == "kill_switch", nil
1108 }
1109 regFiltered := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{"all"}).WithFeatureChecker(checkerTrue))
1110 availableFiltered := regFiltered.AvailableTools(context.Background())
1111 if len(availableFiltered) != 1 {
1112 t.Fatalf("Expected 1 tool with kill_switch enabled, got %d", len(availableFiltered))
1113 }
1114 if availableFiltered[0].Tool.Name != "always_available" {
1115 t.Errorf("Expected always_available, got %s", availableFiltered[0].Tool.Name)
1116 }
1117}
1118
1119func TestFeatureFlagBoth(t *testing.T) {
1120 // Tool that requires "new_feature" AND is disabled by "kill_switch"

Callers

nothing calls this directly

Calls 8

mockToolWithFlagsFunction · 0.85
mustBuildFunction · 0.85
NewBuilderFunction · 0.85
WithToolsetsMethod · 0.80
SetToolsMethod · 0.80
AvailableToolsMethod · 0.80
WithFeatureCheckerMethod · 0.80
mockToolFunction · 0.70

Tested by

no test coverage detected