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

Function TestFeatureFlagBoth

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

Source from the content-addressed store, hash-verified

1117}
1118
1119func TestFeatureFlagBoth(t *testing.T) {
1120 // Tool that requires "new_feature" AND is disabled by "kill_switch"
1121 tools := []ServerTool{
1122 mockToolWithFlags("complex_tool", "toolset1", true, "new_feature", "kill_switch"),
1123 }
1124
1125 // Enable flag not set -> excluded
1126 checker1 := func(_ context.Context, _ string) (bool, error) { return false, nil }
1127 reg1 := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{"all"}).WithFeatureChecker(checker1))
1128 if len(reg1.AvailableTools(context.Background())) != 0 {
1129 t.Error("Tool should be excluded when enable flag is false")
1130 }
1131
1132 // Enable flag set, disable flag not set -> included
1133 checker2 := func(_ context.Context, flag string) (bool, error) { return flag == "new_feature", nil }
1134 reg2 := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{"all"}).WithFeatureChecker(checker2))
1135 if len(reg2.AvailableTools(context.Background())) != 1 {
1136 t.Error("Tool should be included when enable flag is true and disable flag is false")
1137 }
1138
1139 // Enable flag set, disable flag also set -> excluded (disable wins)
1140 checker3 := func(_ context.Context, _ string) (bool, error) { return true, nil }
1141 reg3 := mustBuild(t, NewBuilder().SetTools(tools).WithToolsets([]string{"all"}).WithFeatureChecker(checker3))
1142 if len(reg3.AvailableTools(context.Background())) != 0 {
1143 t.Error("Tool should be excluded when both flags are true (disable wins)")
1144 }
1145}
1146
1147func TestFeatureFlagError(t *testing.T) {
1148 tools := []ServerTool{

Callers

nothing calls this directly

Calls 8

mockToolWithFlagsFunction · 0.85
mustBuildFunction · 0.85
NewBuilderFunction · 0.85
WithFeatureCheckerMethod · 0.80
WithToolsetsMethod · 0.80
SetToolsMethod · 0.80
AvailableToolsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected