From 945c34590677e161a711ccaff0e1077197b1b178 Mon Sep 17 00:00:00 2001 From: Doot Agent Date: Mon, 6 Jul 2026 00:00:59 +0000 Subject: feat: remove Todoist integration entirely Native tasks (native_tasks table) fully replace Todoist. All Todoist API code, store functions, handlers, routes, templates, and tests have been removed. Migration 021 drops the now-unused tasks cache table. Co-Authored-By: Claude Sonnet 4.6 --- test/acceptance_test.go | 81 +++---------------------------------------------- 1 file changed, 4 insertions(+), 77 deletions(-) (limited to 'test') diff --git a/test/acceptance_test.go b/test/acceptance_test.go index d4a386b..e1710bd 100644 --- a/test/acceptance_test.go +++ b/test/acceptance_test.go @@ -73,7 +73,6 @@ func setupTestServer(t *testing.T) (*httptest.Server, *store.Store, *http.Client _ = authService.EnsureDefaultUser("admin", "password") // Create mock API clients - todoistClient := api.NewTodoistClient("test_key") trelloClient := api.NewTrelloClient("test_key", "test_token") cfg := &config.Config{ @@ -82,7 +81,7 @@ func setupTestServer(t *testing.T) (*httptest.Server, *store.Store, *http.Client } // Initialize handlers - h := handlers.New(db, todoistClient, trelloClient, nil, nil, nil, nil, cfg, "test", false) + h := handlers.New(db, trelloClient, nil, nil, nil, nil, cfg, "test", false) // Set up router (same as main.go) r := chi.NewRouter() @@ -103,7 +102,6 @@ func setupTestServer(t *testing.T) (*httptest.Server, *store.Store, *http.Client r.Get("/", h.HandleDashboard) r.Post("/api/refresh", h.HandleRefresh) - r.Get("/api/tasks", h.HandleGetTasks) r.Get("/api/meals", h.HandleGetMeals) r.Get("/api/boards", h.HandleGetBoards) }) @@ -139,21 +137,6 @@ func TestFullWorkflow(t *testing.T) { _ = resp.Body.Close() // Seed database with test data - testTasks := []models.Task{ - { - ID: "task1", - Content: "Buy groceries", - Description: "Milk, eggs, bread", - ProjectID: "proj1", - ProjectName: "Personal", - Priority: 1, - Completed: false, - Labels: []string{"shopping"}, - URL: "https://todoist.com/task/1", - CreatedAt: time.Now(), - }, - } - testBoards := []models.Board{ { ID: "board1", @@ -170,41 +153,11 @@ func TestFullWorkflow(t *testing.T) { }, } - if err := db.SaveTasks(testTasks); err != nil { - t.Fatalf("Failed to seed tasks: %v", err) - } - if err := db.SaveBoards(testBoards); err != nil { t.Fatalf("Failed to seed boards: %v", err) } - // Test 1: GET /api/tasks - t.Run("GetTasks", func(t *testing.T) { - resp, err := client.Get(server.URL + "/api/tasks") - if err != nil { - t.Fatalf("Failed to get tasks: %v", err) - } - defer func() { _ = resp.Body.Close() }() - - if resp.StatusCode != http.StatusOK { - t.Errorf("Expected status 200, got %d", resp.StatusCode) - } - - var tasks []models.Task - if err := json.NewDecoder(resp.Body).Decode(&tasks); err != nil { - t.Fatalf("Failed to decode tasks: %v", err) - } - - if len(tasks) != 1 { - t.Errorf("Expected 1 task, got %d", len(tasks)) - } - - if tasks[0].Content != "Buy groceries" { - t.Errorf("Expected task content 'Buy groceries', got '%s'", tasks[0].Content) - } - }) - - // Test 2: GET /api/boards + // Test 1: GET /api/boards t.Run("GetBoards", func(t *testing.T) { resp, err := client.Get(server.URL + "/api/boards") if err != nil { @@ -285,39 +238,13 @@ func TestFullWorkflow(t *testing.T) { // TestCaching tests the caching behavior func TestCaching(t *testing.T) { - server, db, client, cleanup := setupTestServer(t) + server, _, client, cleanup := setupTestServer(t) defer cleanup() // Login _, _ = client.Get(server.URL + "/test/login") - // Seed initial data - testTasks := []models.Task{ - { - ID: "task1", - Content: "Initial task", - }, - } - _ = db.SaveTasks(testTasks) - _ = db.UpdateCacheMetadata("todoist_tasks", 5) - - // Test 1: First request should use cache - t.Run("UsesCache", func(t *testing.T) { - resp, err := client.Get(server.URL + "/api/tasks") - if err != nil { - t.Fatalf("Failed to get tasks: %v", err) - } - defer func() { _ = resp.Body.Close() }() - - var tasks []models.Task - _ = json.NewDecoder(resp.Body).Decode(&tasks) - - if len(tasks) != 1 { - t.Errorf("Expected 1 task from cache, got %d", len(tasks)) - } - }) - - // Test 2: Refresh should invalidate cache + // Test: Refresh should invalidate cache t.Run("RefreshInvalidatesCache", func(t *testing.T) { // Force refresh resp, err := client.Post(server.URL+"/api/refresh", "application/json", nil) -- cgit v1.2.3