test(activity): add missing cache layer unit tests #326

Merged
fuzzy merged 1 commit from phase08-cache-tests into main 2026-07-07 13:05:52 +00:00
Owner

What

Add missing unit tests for the cache layer, completing #270.

New tests

  • TestOpenWithRecoveryCorruptedFile — writes garbage to a file, verifies OpenWithRecovery detects corruption, removes the file, and creates a fresh valid database
  • TestCheckIntegrityFileBased — verifies CheckIntegrity() passes on a fresh file-based DB
  • TestViewWindowGetter — verifies the Window() getter returns an empty window before load
  • isCorruptErr — handles both ErrCorrupted sentinel and modernc.org/sqlite's "not a database" error string

Coverage

91.3% → 91.9% (uncovered lines are all unreachable error branches)

References: #270, #267, #268, #269

Testing

  • 5 new subtests + existing = all pass
  • go test -race ./... — all pass
## What Add missing unit tests for the cache layer, completing #270. ### New tests - **TestOpenWithRecoveryCorruptedFile** — writes garbage to a file, verifies `OpenWithRecovery` detects corruption, removes the file, and creates a fresh valid database - **TestCheckIntegrityFileBased** — verifies `CheckIntegrity()` passes on a fresh file-based DB - **TestViewWindowGetter** — verifies the `Window()` getter returns an empty window before load - **isCorruptErr** — handles both `ErrCorrupted` sentinel and modernc.org/sqlite's "not a database" error string ### Coverage 91.3% → **91.9%** (uncovered lines are all unreachable error branches) References: #270, #267, #268, #269 ## Testing - [x] 5 new subtests + existing = all pass - [x] `go test -race ./...` — all pass
test(activity): add missing cache layer unit tests
All checks were successful
Test and Release / test (pull_request) Successful in 3m50s
Test and Release / lint (pull_request) Successful in 4m21s
7f089d8477
- OpenWithRecovery with corrupted file: writes garbage, verifies
  recovery creates a fresh valid database
- CheckIntegrity on file-based DB: verifies fresh file passes
- isCorruptErr() handles both ErrCorrupted sentinel and
  modernc.org/sqlite 'not a database' error string
- Window() getter test for View
- Open error path (ping failure) coverage via invalid path test
- Coverage improved from 91.3% to 91.9%

Ref: #270, #267, #268, #269
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-07 13:02:04 +00:00
fuzzy added this to the Steeper project 2026-07-07 13:02:24 +00:00
fuzzy self-assigned this 2026-07-07 13:02:26 +00:00
the.auditor left a comment

Review

Result: Approved — no blocking issues.

Summary: Adds cache layer test coverage. New isCorruptErr() helper handles both ErrCorrupted sentinel and modernc.org/sqlite's raw "not a database" error string — used by OpenWithRecovery for robust corruption detection. Tests: corrupted file recovery, file-based integrity check, view Window() getter. ROADMAP2.md updated.

Minor: TestOpenReturnsErrorOnPingFailure duplicates existing TestOpenInvalidPath (same path, same assertion). Non-blocking.

Checklist:

  • Correctness: isCorruptErr handles both error paths correctly, recovery works on garbage files
  • Completeness: Closes #270 — CRUD, TTL/staleness, edge cases (corrupted) all tested
  • Test coverage: 5 new subtests covering corrupted file recovery, file-based integrity, ping failure, window getter
  • Race-safe: go test -race passes
## Review **Result: Approved** — no blocking issues. **Summary:** Adds cache layer test coverage. New `isCorruptErr()` helper handles both `ErrCorrupted` sentinel and modernc.org/sqlite's raw "not a database" error string — used by `OpenWithRecovery` for robust corruption detection. Tests: corrupted file recovery, file-based integrity check, view Window() getter. ROADMAP2.md updated. **Minor:** `TestOpenReturnsErrorOnPingFailure` duplicates existing `TestOpenInvalidPath` (same path, same assertion). Non-blocking. **Checklist:** - Correctness: ✅ `isCorruptErr` handles both error paths correctly, recovery works on garbage files - Completeness: ✅ Closes #270 — CRUD, TTL/staleness, edge cases (corrupted) all tested - Test coverage: ✅ 5 new subtests covering corrupted file recovery, file-based integrity, ping failure, window getter - Race-safe: ✅ `go test -race` passes
fuzzy merged commit 7f089d8477 into main 2026-07-07 13:05:52 +00:00
fuzzy deleted branch phase08-cache-tests 2026-07-07 13:05:52 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/steeper!326
No description provided.