Memory Appendix
Repo Test Coverage
Every new function added to database/repo/ must ship with extensive tests covering happy path, error branches, and edge cases
Source memory file:
feedback_repo_test_coverage.md· Category: Feedback / working-preference This is a verbatim dump of Claude's persistent memory for the Octopus project. Rendered inside a code block so nothing is altered.
---
name: Repository functions need extensive tests
description: Every new function added to database/repo/ must ship with extensive tests covering happy path, error branches, and edge cases
type: feedback
originSessionId: 4a756616-78f2-4e8f-a906-fd34e36a1824
---
Every new function added to `database/repo/` must ship with extensive tests in the same commit. No exceptions.
**Why:** This is a critical system with a single dev (the user). Each commit must demonstrably work end-to-end. Untested repo functions become production failures because they hit the database directly and there's no second pair of eyes to catch a missed branch. The user has explicitly invested in pushing repo coverage upward (sweep tests, sqlmock infrastructure, fault injection) — new functions must not erode that floor.
**How to apply:**
When adding or modifying a function in `database/repo/`:
1. **Happy path** — at minimum one test where the function returns the expected result. For reads, exercise the scan loop. For writes, verify the insert/update/delete fires.
2. **Error branches** — use the existing `faultDB` / `faultCache` infrastructure (see `fault_injection_internal_test.go`) to inject ExecuteQuery/ExecuteStatement failures and assert the error propagates.
3. **Cache paths** (if the function caches) — use `cachedCache` (see `sqlmock_cache_hits_internal_test.go`) to exercise both cache-miss and cache-hit branches.
4. **Edge cases** — empty result sets, nil pointer fields, transaction rollback, pagination boundaries.
**Where to put the tests:**
- White-box unit tests with sqlmock → new `sqlmock_<feature>_internal_test.go` (package `repo`, not `repo_test`) or extend an existing `TestMock_Sweep*` block.
- Integration tests against real Postgres → `<source>_coverage_test.go` using `testhelpers.SkipIfShort` + `testhelpers.RequirePostgres`.
**Patterns already established (reuse, don't reinvent):**
- `newMockRepo(t)` returns a `*Repository` wired to sqlmock — use this for unit tests.
- Vendor/client/product columns + row helpers live in the existing `sqlmock_*_internal_test.go` files; reuse them rather than redefining.
- For `[]uint64` parameters that hit `= ANY($1)`, sqlmock can't bind the slice — fall back to integration tests for those happy paths.
**Pre-commit verification:** run `go test ./database/repo -count=1 -coverprofile=/tmp/repo-cover.out` and confirm the new function shows non-zero coverage in `go tool cover -func=/tmp/repo-cover.out`.Og Image Per Page Routes
When adding /blog/[slug], /cards/[slug], or similar shareable page types to octopus-website, ensure the corresponding /og/<section>/[slug] route handler exists
Secret Row Column Stack
Client-portal MUI theme defaults Stack to direction=row; set direction=column explicitly for vertical layouts