init
This commit is contained in:
3
backend/.claude/agent-memory/tester/MEMORY.md
Normal file
3
backend/.claude/agent-memory/tester/MEMORY.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Tester Agent Memory
|
||||
|
||||
- [Test database setup pattern](feedback_test_db_setup.md) — store.New appends query params; use os.CreateTemp instead of ":memory:" URIs
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
name: Test database setup pattern
|
||||
description: How to create isolated test databases for store and handler tests in this project
|
||||
type: feedback
|
||||
---
|
||||
|
||||
Use `os.CreateTemp` to create a temporary SQLite file for each test. Pass that file path to `store.New`.
|
||||
|
||||
**Why:** `store.New` always appends `?_journal_mode=WAL&_foreign_keys=ON` to the path argument. If you pass a URI like `file:name?mode=memory&cache=shared`, the result is a malformed DSN (`...?mode=memory&cache=shared?_journal_mode=WAL&...`) that SQLite rejects with "no such cache mode: shared".
|
||||
|
||||
**How to apply:** In every `newTestStore` / `newHandlerWithStore` helper, do:
|
||||
```go
|
||||
f, _ := os.CreateTemp("", "krafttrainer-test-*.db")
|
||||
f.Close()
|
||||
dbPath := f.Name()
|
||||
s, err := store.New(dbPath)
|
||||
t.Cleanup(func() { s.Close(); os.Remove(dbPath) })
|
||||
```
|
||||
Reference in New Issue
Block a user