summaryrefslogtreecommitdiff
path: root/internal/store
diff options
context:
space:
mode:
authorAgent <agent@workspace.local>2026-03-18 10:15:54 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-19 00:11:16 +0000
commit5723d6635f9462e60960b0f9548273d95a86d8f3 (patch)
tree2ce8ee5829f317012d9b1b3f9097fbfb923192c0 /internal/store
parente85b42d373de55781af9d699b246c0d6a492aec1 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/store')
-rw-r--r--internal/store/sqlite_test.go37
1 files changed, 37 insertions, 0 deletions
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
// =============================================================================