docs: update README, Obsidian docs, and gap backlog after test optimization
- Update test count: 286/288 passing (was 222/224) - Document TestMain per-package architecture - Document TruncateTables optimization (~60% faster) - Add local-dev-2.sh tee streaming for real-time test output - Fix flaky admin reserve walk-in tests (time.Now → noon tomorrow) - Add gap backlog item #51 for completed test optimization work
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# Crussell
|
||||
#KM|> **Last Updated:** May 2026
|
||||
#KM|> **Last Updated:** May 2026 — Test infrastructure overhaul, 286/288 tests passing
|
||||
Crussell is a **full‑stack application** that powers a nail‑bar / salon booking service. The repository is split into a **Go** backend and a **SvelteKit** front‑end, both of which are containerised with Docker. A lightweight **SabreDAV** instance is also exposed so that the salon can offer WebDAV access to clients.
|
||||
|
||||
## 📦 Project Structure
|
||||
@@ -122,40 +122,43 @@ Crussell has a comprehensive Go testing infrastructure located in `backend/testu
|
||||
cd backend
|
||||
|
||||
# Run all tests
|
||||
go test ./...
|
||||
go test -tags test ./...
|
||||
|
||||
# Run with verbose output
|
||||
go test -v ./...
|
||||
go test -tags test -v ./...
|
||||
|
||||
# Run specific test file
|
||||
go test -v ./handlers/bookings
|
||||
# Run specific test package
|
||||
go test -tags test -v ./handlers/bookings
|
||||
|
||||
# Run tests matching pattern
|
||||
go test -v -run "TestBooking" ./...
|
||||
go test -tags test -v -run "TestBooking" ./...
|
||||
|
||||
# Run tests twice to catch state leakage
|
||||
go test -tags test -v -p 1 -count=2 ./...
|
||||
```
|
||||
|
||||
### Test Database Setup
|
||||
|
||||
Tests use a dedicated PostgreSQL database. Set the connection string via:
|
||||
Tests use a dedicated PostgreSQL database (`crussell_test`). Set the connection via environment variables:
|
||||
|
||||
```bash
|
||||
export TEST_DB_DSN="postgres://user:pass@localhost:5432/crussell_test?sslmode=disable"
|
||||
go test ./...
|
||||
export POSTGRES_USER=myuser POSTGRES_PASSWORD=mypassword POSTGRES_HOST=localhost POSTGRES_DB=crussell_test GO_TESTING=1
|
||||
go test -tags test ./...
|
||||
```
|
||||
|
||||
Default DSN: `postgres://myuser:mypassword@localhost:5432/crussell_test?sslmode=disable`
|
||||
|
||||
### Test Conventions
|
||||
### Test Architecture
|
||||
|
||||
- All test files use `//go:build test` build tag
|
||||
- Database is migrated fresh per test run via `testdb.Migrate()`
|
||||
- Tables are truncated between tests via `testdb.TruncateTables()`
|
||||
- Each test package has a `TestMain` that runs schema migration **once** (not per test)
|
||||
- Between tests, `TruncateTables()` clears data via `TRUNCATE TABLE ... CASCADE` — fast, no schema rebuild
|
||||
- Tests run sequentially (`-p 1`) because all packages share the same test database
|
||||
- Test tokens use a fixed secret: `test-secret-key-for-testing-only`
|
||||
- Fixtures auto-generate unique emails to avoid conflicts
|
||||
- `-count=N` is safe to increase for flaky test detection (each count re-runs TestMain + all tests)
|
||||
|
||||
### Test Coverage
|
||||
|
||||
222/224 tests passing across all handler packages. Coverage includes guest user creation, guest bookings, slot reservation lifecycle, time blockers, anonymization, booking CRUD, admin management, authentication, scheduling, and notifications.
|
||||
**286/288 tests passing** across all handler packages. Coverage includes guest user creation, guest bookings, slot reservation lifecycle, time blockers, anonymization, booking CRUD, admin management, authentication, scheduling, notifications, portfolio, user profiles, deposit system, edit requests, and discount campaigns.
|
||||
|
||||
## 📂 Environment Variables
|
||||
|
||||
|
||||
Reference in New Issue
Block a user