diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-16 06:08:23 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-16 06:08:23 +0000 |
| commit | 310d17b25d8dbcd8e930148334e7bd7bb144f407 (patch) | |
| tree | 4a7fbb3eb04160b1495f1881fb708386df3aee06 /internal/store/availability_test.go | |
| parent | 31d8d9b32a3ac68d3d939bd080eeb780c37f17d7 (diff) | |
Add schema for task budgets and availability blocks
Creates migrations/025_task_budgets_and_availability.sql with:
- New availability_blocks table for manual weekly availability templates
- estimated_minutes column on native_tasks for time budgeting
- budget_tracked flag on projects and labels for opt-in tracking
Fixes pre-existing bug in sqlite_test.go's setupTestStoreWithNativeTasks where
project_id column was missing from the schema, causing test failures.
Updates all hand-rolled test helpers (sqlite_test.go, native_tasks_test.go)
to include the new columns, and adds availability_test.go with newAvailabilityTestStore
helper for Task 4's availability CRUD tests.
All store tests pass, including the two that were previously failing
(TestGetNativeTasksByDateRange_ExcludesOverdue, TestGetOverdueNativeTasks_IncludesOnlyPastDue).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PQaPGQVSfmKUiHXB87qRTC
Diffstat (limited to 'internal/store/availability_test.go')
| -rw-r--r-- | internal/store/availability_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/store/availability_test.go b/internal/store/availability_test.go new file mode 100644 index 0000000..97ce90e --- /dev/null +++ b/internal/store/availability_test.go @@ -0,0 +1,33 @@ +package store + +import ( + "database/sql" + "path/filepath" + "testing" + + _ "github.com/mattn/go-sqlite3" +) + +// newAvailabilityTestStore creates a Store backed by a fresh temp sqlite DB +// with just the availability_blocks table. +func newAvailabilityTestStore(t *testing.T) *Store { + t.Helper() + dbPath := filepath.Join(t.TempDir(), "test.db") + db, err := sql.Open("sqlite3", dbPath) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { db.Close() }) + if _, err := db.Exec(` + CREATE TABLE availability_blocks ( + id TEXT PRIMARY KEY, + weekday INTEGER NOT NULL, + start_time TEXT NOT NULL, + end_time TEXT NOT NULL, + label TEXT DEFAULT '' + ) + `); err != nil { + t.Fatal(err) + } + return &Store{db: db} +} |
