Compare commits
3
Commits
b549014a68
...
9e85bc766b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e85bc766b | ||
|
|
428e250b4f | ||
|
|
85c043ad7f |
+2
-1
@@ -23,7 +23,8 @@ S3_BUCKET=crussell
|
||||
S3_PROFILE_PICS_BUCKET=crussell-profile-pics
|
||||
AWS_REGION=eu-west-2
|
||||
|
||||
# Prod: Set R2_ENDPOINT for Cloudflare R2 (overrides S3_* vars in non-dev builds)
|
||||
# Prod only: Cloudflare R2 (overrides S3_* vars in non-dev builds).
|
||||
# Local dev uses the S3_* vars above (from .env). Not needed for local builds.
|
||||
R2_ENDPOINT=
|
||||
# R2_ACCESS_KEY=<your-access-key>
|
||||
# R2_SECRET_KEY=<your-secret-key>
|
||||
|
||||
@@ -41,6 +41,13 @@ if [ -n "$BACKEND_FILES" ]; then
|
||||
fi
|
||||
cd ..
|
||||
|
||||
printf "${YELLOW}Checking golangci-lint...${NC}\n"
|
||||
if ! cd backend && golangci-lint run ./... --timeout 3m 2>&1; then
|
||||
printf "${RED}✖ golangci-lint failed${NC}\n"
|
||||
FAILED=1
|
||||
fi
|
||||
cd ..
|
||||
|
||||
printf "${YELLOW}Checking staticcheck...${NC}\n"
|
||||
if ! cd backend && staticcheck -tags "test,dev" ./... 2>&1; then
|
||||
printf "${RED}✖ staticcheck failed${NC}\n"
|
||||
|
||||
@@ -76,11 +76,22 @@ Default logins (password: `password`):
|
||||
```bash
|
||||
cd backend && go build -o bin/backend ./main.go
|
||||
cd frontend && npm ci && npm run build
|
||||
cd backend && go test -tags "test,dev" -count=1 -parallel 8 ./... # 1,251/1,255 tests passed, 4 skipped (~13s)
|
||||
cd backend && go test -tags "test,dev" -count=1 -parallel 8 ./... # ~1,642 tests passed (~13s)
|
||||
cd backend && go test -tags "test,dev" -count=1 -race -timeout 480s ./... # race detector (all packages, ~4min)
|
||||
cd backend && go test -tags "test,dev" -count=10 -parallel 8 ./... # thorough verification (~2-3min)
|
||||
```
|
||||
|
||||
### Pre-commit hooks
|
||||
|
||||
`.githooks/pre-commit` runs on every commit (configured via `git config core.hooksPath .githooks`):
|
||||
- **Frontend**: `prettier --write` auto-format, then `eslint` all files
|
||||
- **Backend** (only if `backend/` changed): `go vet`, `golangci-lint` (3m timeout), `staticcheck`, `gosec`, `go mod tidy` check
|
||||
- **Global**: `gitleaks` secret scan (skips gracefully if not installed)
|
||||
|
||||
To bypass: `git commit --no-verify`.
|
||||
|
||||
### CI caching
|
||||
|
||||
CI caches Go modules (`~/go/pkg/mod`) and npm dependencies (`~/.npm`, `node_modules`) via `actions/cache` — keyed on `go.sum` and `package-lock.json` respectively. Cache is served by Gitea's built-in cache server at `git.popertots.com`. First run downloads everything (~3m35s), subsequent runs restore from cache in seconds.
|
||||
|
||||
## Full Documentation
|
||||
|
||||
@@ -130,6 +130,7 @@ Campaign lifecycle: `draft → active → completed` (or any → `cancelled`, `a
|
||||
- **No automated DB backups** — no `pg_dump` cron or point-in-time recovery
|
||||
- **No API documentation** — no OpenAPI/Swagger spec
|
||||
- **L3 progressive rate limiting** — per-IP dual-window (30 req/5s burst + 120 req/60s sustained) on login/register. Account lockout after 5 failures (progressive 15min→2h).
|
||||
- **A11y checks via Svelte 5 compiler** — ESLint a11y plugin rules removed; compiler built-in checks used instead
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -215,7 +216,7 @@ npm run dev # Dev server with HMR
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
go test -tags "test,dev" ./... # 1,251/1,255 tests passed, 4 skipped
|
||||
go test -tags "test,dev" ./... # ~1,642 tests passed
|
||||
go test -tags "test,dev" -v -run TestName ./... # Single test
|
||||
```
|
||||
|
||||
|
||||
@@ -1244,7 +1244,7 @@ Files with this pattern: `bookings.go` (4 handlers), `custom_services.go`, `user
|
||||
|
||||
### Test Coverage
|
||||
|
||||
**1,251/1,255 tests run** across all packages (4 skipped, 0 failures). Recent additions: centralised job scheduler tests (3 — RegisterAll count, schedules, handler signatures), scheduled-cleanup handler tests (21 — NotifyUnpaidOneWeek/Month, TransitionDiscountCampaigns, CleanupExpiredVerificationCodes/RefreshTokens), GDPR export cache cleanup (4), stale login entry cleanup (4), rate limiter cleanup tests (6), rate limiter production behavior tests (6). Self-blocking prevention tests (excludeUserID coverage for GetAvailableHours, EditBookingHandler, AdminRescheduleBookingHandler, ReserveSlotHandler anon IP cleanup, AdminReserveSlotHandler anon IP cleanup), closing_time tests (3), content-type middleware tests (2), booking handler tests (FOR UPDATE overlap checks, admin reserve with closing_time, gift card buy with VAT), and the new admin reservation cancel coverage (12 tests covering walkin + callin + isolation + no-op + idempotency + response format parity, plus 2 inverse-isolation tests on the user-side `cancel_reservation_test.go` to prove the two cancel endpoints are properly partitioned by their WHERE clauses). Booking integration tests continue to expand: duplicate completion guard, daily stamp cap (handler + SQL subquery), invalid status transitions, sequential edit, timezone independence, and past-booking no-show guard. The `clock` package itself has tests for Now() and clock interface correctness.
|
||||
**~1,642 tests run** across all packages (0 failures). Coverage improved from 50.4% to 65.0% via 56 new test files covering booking handlers, user handlers, payments (giftcards, till, refunds), DAV, auth, middleware, validators, zxcvbn, and scheduling. Key additions: coverage improvement tests (bookings_coverage_test.go, user_coverage_test.go, payments coverage expansion — all meaningful error-path tests, not padding), split-lunch detection tests, savepoint/transaction-context tests for time-sensitive operations, VAT lifecycle and parallel-deadlock regression tests, and cleanup of 10 dead test functions flagged by staticcheck U1000.
|
||||
|
||||
| Package | Coverage Area |
|
||||
|---------|--------------|
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Testing Architecture & DB Management
|
||||
|
||||
**Last Updated:** July 2026 (v4 — centralised job scheduler tests, 1,255 tests)
|
||||
**Last Updated:** July 2026 (v5 — coverage 50.4%→65.0%, ~1,642 tests)
|
||||
|
||||
---
|
||||
|
||||
@@ -501,7 +501,7 @@ This appears in `TestAccount_DeleteGuest` and `TestLoyalty_Get`. The `dav.Servic
|
||||
|--------|-------|
|
||||
| Quick check (`-count=1`) | **~13s** |
|
||||
| Packages | 19 tested, 0 failures |
|
||||
| Tests | 1,251/1,255 passed, 4 skipped, 0 failing |
|
||||
| Tests | ~1,642 passed, 0 failing |
|
||||
|
||||
New test additions in this batch:
|
||||
| Test | Coverage |
|
||||
@@ -520,7 +520,7 @@ New test additions in this batch:
|
||||
| `TestCancelReservation_DoesNotTouchAnonReservations` | Inverse-isolation test — user cancel ignores `RESERVATION:anon:%` (defensive — the WHERE clause only matches `RESERVATION:user:%`) |
|
||||
| `TestCancelReservation_DoesNotTouchAdminReservations` | Inverse-isolation test — user cancel ignores `RESERVATION:admin:%`. Pairs with the admin-side test that verifies admin cancel ignores `RESERVATION:user:%`. Proves the two endpoints are properly partitioned. |
|
||||
|
||||
**Total tests:** 1,251/1,255 run (4 skipped) across all packages. 0 failures. Growth driven by new `clock` package tests, `closing_time` tests (3), `contenttype` middleware tests (2), expanded booking/payment handler test coverage, admin reservation cancel coverage (12 tests: walkin + callin success, isolation, no-op, unauth, empty ctx, walkin+callin coexistence, anon untouched, response format parity, overlapping reservations deleted, user reservations untouched, idempotent double-cancel), centralised job scheduler tests (3: RegisterAll count, schedules, handler signatures), scheduled-cleanup handler tests (21: NotifyUnpaidOneWeek/Month, TransitionDiscountCampaigns, CleanupExpiredVerificationCodes/RefreshTokens), GDPR export cache cleanup (4), stale login entry cleanup (4), rate limiter cleanup prod tests (6), and rate limiter production behavior tests (6). Two inverse-isolation tests added to the existing user-side `cancel_reservation_test.go` to verify the user and admin cancel endpoints are properly partitioned by `RESERVATION:user:%` / `RESERVATION:admin:%` WHERE clauses.
|
||||
**Total tests:** ~1,642 passed across all packages. 0 failures. Growth driven by: coverage improvement pass (new test files for bookings, user, payments, giftcards, till, refunds, DAV, auth, middleware, validators, zxcvbn — 56 new files, coverage 50.4%→65.0%), VAT lifecycle and parallel-deadlock regression tests, savepoint/transaction-context pattern for time-sensitive tests, split-lunch detection tests, and removal of 10 dead test functions flagged by staticcheck U1000.
|
||||
|
||||
### What Drives Test Time
|
||||
|
||||
@@ -637,7 +637,7 @@ This shouldn't appear anymore — the auth package's TestMain was updated to use
|
||||
|
||||
### Q: What's the total test count?
|
||||
|
||||
1,251/1,255 tests run across all packages (4 skipped). 0 failures.
|
||||
~1,642 tests run across all packages. 0 failures.
|
||||
|
||||
**Notable new tests:** Centralised job scheduler tests (3 — RegisterAll count, schedules, handler signatures), scheduled-cleanup handler tests (21 — NotifyUnpaidOneWeek/Month, TransitionDiscountCampaigns, CleanupExpiredVerificationCodes/RefreshTokens), GDPR export cache cleanup (4), stale login entry cleanup (4), rate limiter cleanup tests (6), rate limiter production behavior tests (6). Duplicate completion guard (idempotent second `"completed"` call), daily stamp cap (two completions same day → 1 stamp), invalid status transitions (no-show→completed rejected with 400), sequential edit (two edits in sequence), timezone independence (UTC in, UTC out — no shift), past-booking no-show guard (past confirmed booking cancelled → `client_cancelled`, not `no_show`). New closing_time tests (3), content-type middleware tests (2), clock package tests, expanded admin reserve overlap tests, expanded gift card buy flow tests with VAT, and full admin reservation cancel coverage (12 tests covering walkin + callin + isolation + no-op + idempotency + response format parity).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user