diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-08-06 18:19:27 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-08-06 18:19:27 +0000 |
| commit | 06450fe69ade2928deb9274bb67b7ba60d394b4f (patch) | |
| tree | 328c3e2f5608663669d75330bfde1e61ab713499 /internal/handlers/handlers_test.go | |
| parent | f7d18eae924a221f12293c3063e46b791468623f (diff) | |
Remove the feature toggle system (dead code)
Audited it (couldn't query the live DB directly -- auto-mode classifier
blocks direct production reads without prior approval -- so this is a
code-only audit): GetFeatureToggles/SetFeatureEnabled/IsFeatureEnabled/
CreateFeatureToggle/DeleteFeatureToggle had exactly one caller each, all
inside their own CRUD handlers. Nothing anywhere else in the codebase
read a toggle's Enabled state to gate any actual behavior -- confirmed
by grepping every remaining .Enabled/IsFeatureEnabled reference back to
either this dead code or its own tests. It was pure UI-managed CRUD with
no consumer, unlike Trusted Agents (wired into agent.go/websocket.go)
or Data Sources (wired into the sync pipeline) which stayed.
Removes the Settings page section, the three /settings/features* routes
and handlers, the five Store methods, the FeatureToggle model, and adds
028_drop_feature_toggles.sql (next free migration number, per this
repo's convention of never renumbering -- see 021_drop_tasks.sql for
the same drop-table-forward pattern) to drop the now-unused table.
Also removed the now-dead tests for all of the above.
go build ./... and go test ./... both clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ7ikw2ukGJFTHE3bJS7zL
Diffstat (limited to 'internal/handlers/handlers_test.go')
| -rw-r--r-- | internal/handlers/handlers_test.go | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index 9d92faa..4c776b0 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -1122,116 +1122,6 @@ func TestHandleUnifiedAdd_MissingContent(t *testing.T) { } // ============================================================================= -// Settings Handler Tests -// ============================================================================= - -func TestHandleToggleFeature(t *testing.T) { - db, cleanup := setupTestDB(t) - defer cleanup() - - h := &Handler{ - store: db, - renderer: newTestRenderer(), - config: &config.Config{}, - } - - // Create a feature toggle - _ = db.CreateFeatureToggle("test_feature", "Test feature", false) - - req := httptest.NewRequest("POST", "/settings/feature/toggle", nil) - req.Form = map[string][]string{ - "name": {"test_feature"}, - "enabled": {"true"}, - } - w := httptest.NewRecorder() - - h.HandleToggleFeature(w, req) - - if w.Code != http.StatusOK { - t.Errorf("Expected status 200, got %d", w.Code) - } - - // Verify feature was enabled - if !db.IsFeatureEnabled("test_feature") { - t.Error("Feature should be enabled after toggle") - } -} - -func TestHandleCreateFeature(t *testing.T) { - db, cleanup := setupTestDB(t) - defer cleanup() - - h := &Handler{ - store: db, - renderer: newTestRenderer(), - config: &config.Config{}, - } - - req := httptest.NewRequest("POST", "/settings/feature/create", nil) - req.Form = map[string][]string{ - "name": {"new_feature"}, - "description": {"A new feature"}, - } - w := httptest.NewRecorder() - - h.HandleCreateFeature(w, req) - - if w.Code != http.StatusOK { - t.Errorf("Expected status 200, got %d", w.Code) - } - - // Verify feature was created - toggles, _ := db.GetFeatureToggles() - found := false - for _, t := range toggles { - if t.Name == "new_feature" { - found = true - break - } - } - if !found { - t.Error("Feature should be created") - } -} - -func TestHandleDeleteFeature(t *testing.T) { - db, cleanup := setupTestDB(t) - defer cleanup() - - h := &Handler{ - store: db, - renderer: newTestRenderer(), - config: &config.Config{}, - } - - // Create a feature to delete - _ = db.CreateFeatureToggle("delete_me", "To be deleted", false) - - req := httptest.NewRequest("DELETE", "/settings/feature/delete_me", nil) - - // Add chi URL params - rctx := chi.NewRouteContext() - rctx.URLParams.Add("name", "delete_me") - req = req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, rctx)) - - w := httptest.NewRecorder() - - h.HandleDeleteFeature(w, req) - - if w.Code != http.StatusOK { - t.Errorf("Expected status 200, got %d", w.Code) - } - - // Verify feature was deleted - toggles, _ := db.GetFeatureToggles() - for _, toggle := range toggles { - if toggle.Name == "delete_me" { - t.Error("Feature should be deleted") - } - } -} - -// ============================================================================= // Response Helper Tests // ============================================================================= |
