(t *testing.T)
| 1117 | } |
| 1118 | |
| 1119 | func 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 | |
| 1147 | func TestFeatureFlagError(t *testing.T) { |
| 1148 | tools := []ServerTool{ |
nothing calls this directly
no test coverage detected