summaryrefslogtreecommitdiff
path: root/internal/store
diff options
context:
space:
mode:
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
// =============================================================================