From 5723d6635f9462e60960b0f9548273d95a86d8f3 Mon Sep 17 00:00:00 2001 From: Agent Date: Wed, 18 Mar 2026 10:15:54 +0000 Subject: test: add coverage for planning tab, meals, Google Tasks, bug handlers, completed task parsing - HandleTabPlanning: happy-path test verifying tasks/cards land in correct sections (scheduled/unscheduled/upcoming); boundary test confirming a task due exactly at midnight of tomorrow lands in Upcoming, not Scheduled - HandleTabMeals: grouping test verifying two meals sharing date+mealType produce one CombinedMeal with both recipe names merged - Google Tasks GetTasksByDateRange: four boundary tests (start inclusive, end exclusive, no-due-date always included, out-of-range excluded) using redirectingTransport mock server pattern - HandleGetBugs: data assertions verifying bug list and empty-list cases - HandleReportBug: success test verifying bug is saved and bugs template is re-rendered - GetCompletedTasks: timestamp parsing test ensuring CompletedAt is not zero when inserted with a known "2006-01-02 15:04:05" string Co-Authored-By: Claude Sonnet 4.6 --- internal/store/sqlite_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'internal/store/sqlite_test.go') diff --git a/internal/store/sqlite_test.go b/internal/store/sqlite_test.go index 9c56252..c6c428a 100644 --- a/internal/store/sqlite_test.go +++ b/internal/store/sqlite_test.go @@ -1084,6 +1084,43 @@ func TestCompletedTasks_Limit(t *testing.T) { } } +// TestGetCompletedTasks_CompletedAtIsParsed inserts a row with a known +// completed_at string and verifies that CompletedAt is parsed correctly (not +// left as the zero value). +func TestGetCompletedTasks_CompletedAtIsParsed(t *testing.T) { + s := setupTestStoreWithCompletedTasks(t) + defer func() { _ = s.Close() }() + + // Insert directly with a known timestamp in the format GetCompletedTasks parses. + knownTimestamp := "2026-03-15 14:30:00" + _, err := s.db.Exec( + `INSERT INTO completed_tasks (source, source_id, title, completed_at) VALUES (?, ?, ?, ?)`, + "todoist", "task-ts-test", "Timestamp Test Task", knownTimestamp, + ) + if err != nil { + t.Fatalf("Failed to insert task: %v", err) + } + + tasks, err := s.GetCompletedTasks(10) + if err != nil { + t.Fatalf("GetCompletedTasks failed: %v", err) + } + if len(tasks) != 1 { + t.Fatalf("Expected 1 task, got %d", len(tasks)) + } + + got := tasks[0].CompletedAt + if got.IsZero() { + t.Fatal("Expected CompletedAt to be parsed, got zero time") + } + + // GetCompletedTasks parses with "2006-01-02 15:04:05" (no timezone → UTC). + want := time.Date(2026, 3, 15, 14, 30, 0, 0, time.UTC) + if !got.Equal(want) { + t.Errorf("CompletedAt: got %v, want %v", got, want) + } +} + // ============================================================================= // Source Configuration Tests // ============================================================================= -- cgit v1.2.3