Fix: cover buildHeatmapWeeks break — unblock coverage gate (bookshelf-q9sg) #548

Merged
zombor merged 1 commit from bd-bookshelf-q9sg into main 2026-06-13 01:34:30 +00:00
Owner

Summary

  • Adds a deterministic Ginkgo spec in internal/stats/handler_internal_test.go that calls buildHeatmapWeeks with a fixed mid-week now (Wednesday 2024-06-12, verified not Saturday)
  • The new test asserts that Cells[4] (Thursday) in the final week is nil, which forces the if day.After(today) { break } branch on handler.go:200-201 to execute
  • All prior buildHeatmapWeeks tests used now = 2024-06-15 (Saturday), so the final week's loop ran through all 7 days without any day falling after today — leaving the break branch permanently at 0 hits
  • This regression was introduced in bookshelf-o1v2 (#531, commit 2346c366)

Impact

Restores the 100% coverage gate (make coverage: OK — zero uncovered statement blocks), unblocking the 12 open PRs that have been behind the red main.

Test plan

  • go test ./internal/stats/... — 60 specs PASS
  • make coveragecheck-coverage: OK — zero uncovered statement blocks
  • golangci-lint run ./internal/stats/... — 0 issues

Closes bead bookshelf-q9sg on merge.

## Summary - Adds a deterministic Ginkgo spec in `internal/stats/handler_internal_test.go` that calls `buildHeatmapWeeks` with a fixed mid-week `now` (Wednesday 2024-06-12, verified not Saturday) - The new test asserts that `Cells[4]` (Thursday) in the final week is `nil`, which forces the `if day.After(today) { break }` branch on `handler.go:200-201` to execute - All prior `buildHeatmapWeeks` tests used `now = 2024-06-15` (Saturday), so the final week's loop ran through all 7 days without any day falling after today — leaving the break branch permanently at 0 hits - This regression was introduced in bookshelf-o1v2 (#531, commit 2346c366) ## Impact Restores the 100% coverage gate (`make coverage: OK — zero uncovered statement blocks`), unblocking the 12 open PRs that have been behind the red main. ## Test plan - [x] `go test ./internal/stats/...` — 60 specs PASS - [x] `make coverage` — `check-coverage: OK — zero uncovered statement blocks` - [x] `golangci-lint run ./internal/stats/...` — 0 issues Closes bead bookshelf-q9sg on merge.
test(stats): cover buildHeatmapWeeks mid-week break — fix coverage gate (bookshelf-q9sg)
Some checks failed
/ Lint (pull_request) Successful in 2m29s
/ JS Unit Tests (pull_request) Successful in 31s
/ Test (pull_request) Failing after 3m23s
/ E2E Browser (pull_request) Successful in 2m53s
/ Integration (pull_request) Successful in 5m29s
/ E2E API (pull_request) Successful in 4m52s
a1f6752be1
Add a deterministic Ginkgo spec that calls buildHeatmapWeeks with a fixed
Wednesday now (2024-06-12), verifying that Thursday's cell (d=4) in the final
week is nil. This exercises the `if day.After(today) { break }` guard on
handler.go:200-201 that was left uncovered when all prior tests used a Saturday
now (where the final week's loop never encounters a day after today).

The regression was introduced in bookshelf-o1v2 (#531). This restores the
100% coverage gate and unblocks the 12 open PRs behind it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zombor force-pushed bd-bookshelf-q9sg from a1f6752be1
Some checks failed
/ Lint (pull_request) Successful in 2m29s
/ JS Unit Tests (pull_request) Successful in 31s
/ Test (pull_request) Failing after 3m23s
/ E2E Browser (pull_request) Successful in 2m53s
/ Integration (pull_request) Successful in 5m29s
/ E2E API (pull_request) Successful in 4m52s
to 3231944f9c
All checks were successful
/ JS Unit Tests (pull_request) Successful in 34s
/ Lint (pull_request) Successful in 2m32s
/ Test (pull_request) Successful in 3m2s
/ E2E Browser (pull_request) Successful in 4m14s
/ Integration (pull_request) Successful in 6m23s
/ E2E API (pull_request) Successful in 7m33s
2026-06-13 01:22:09 +00:00
Compare
Author
Owner

Code Review — bookshelf-q9sg (PR #548)

Phase 0: DEMO Verification

No DEMO block applies — this is a test-only coverage fix; the coverage gate is verified by CI (green).

Phase 1: Spec Compliance

Single file changed: internal/stats/handler_internal_test.go. The bead requires a test exercising the day.After(today) break at handler.go:200-201. The diff delivers exactly that and nothing else. No scope creep.

Phase 2: Code Quality

Weekday arithmetic verified independently:

  • time.Date(2024, 6, 12, ...) is Wednesday. Go time.Weekday() = 3 (Sunday=0). Confirmed with Python.
  • That week's Sunday = 2024-06-09. Cells[4] = Thursday 2024-06-13, which is after today (2024-06-12).
  • The break at handler.go:200 fires before d=4, leaving Cells[4] as its zero value (nil pointer).
  • Expect(last.Cells[4]).To(BeNil()) directly asserts this. Not a tautology.

Determinism: now is time.Date(2024, 6, 12, 12, 0, 0, 0, time.UTC) — a fixed constant, no time.Now(). Coverage is date-independent and will not flake.

Ginkgo conventions:

  • var (weeks []heatmapWeek) declared at top of Describe block.
  • Invocation in JustBeforeEach, assertion in It.
  • One Expect per It.
  • now declared inside JustBeforeEach (not a varying dep across Context blocks, so no separate BeforeEach needed). Acceptable.

Coverage gate: scripts/check-coverage.sh unchanged. No exclusions added.

No findings.

REVIEW VERDICT: 0 blocker, 0 major, 0 minor

## Code Review — bookshelf-q9sg (PR #548) ### Phase 0: DEMO Verification No DEMO block applies — this is a test-only coverage fix; the coverage gate is verified by CI (green). ### Phase 1: Spec Compliance Single file changed: `internal/stats/handler_internal_test.go`. The bead requires a test exercising the `day.After(today)` break at `handler.go:200-201`. The diff delivers exactly that and nothing else. No scope creep. ### Phase 2: Code Quality **Weekday arithmetic verified independently:** - `time.Date(2024, 6, 12, ...)` is Wednesday. Go `time.Weekday()` = 3 (Sunday=0). Confirmed with Python. - That week's Sunday = 2024-06-09. `Cells[4]` = Thursday 2024-06-13, which is after `today` (2024-06-12). - The break at `handler.go:200` fires before `d=4`, leaving `Cells[4]` as its zero value (nil pointer). - `Expect(last.Cells[4]).To(BeNil())` directly asserts this. Not a tautology. **Determinism:** `now` is `time.Date(2024, 6, 12, 12, 0, 0, 0, time.UTC)` — a fixed constant, no `time.Now()`. Coverage is date-independent and will not flake. **Ginkgo conventions:** - `var (weeks []heatmapWeek)` declared at top of `Describe` block. - Invocation in `JustBeforeEach`, assertion in `It`. - One `Expect` per `It`. - `now` declared inside `JustBeforeEach` (not a varying dep across `Context` blocks, so no separate `BeforeEach` needed). Acceptable. **Coverage gate:** `scripts/check-coverage.sh` unchanged. No exclusions added. No findings. REVIEW VERDICT: 0 blocker, 0 major, 0 minor
zombor merged commit bc1a49bfda into main 2026-06-13 01:34:30 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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
zombor/pergamum!548
No description provided.