(t *testing.T)
| 1090 | } |
| 1091 | |
| 1092 | func 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 | |
| 1119 | func TestFeatureFlagBoth(t *testing.T) { |
| 1120 | // Tool that requires "new_feature" AND is disabled by "kill_switch" |
nothing calls this directly
no test coverage detected