summaryrefslogtreecommitdiff
path: root/internal/store/availability_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/store/availability_test.go')
-rw-r--r--internal/store/availability_test.go33
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}
+}