Fix: cover buildHeatmapWeeks break — unblock coverage gate (bookshelf-q9sg) #548
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bd-bookshelf-q9sg"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
internal/stats/handler_internal_test.gothat callsbuildHeatmapWeekswith a fixed mid-weeknow(Wednesday 2024-06-12, verified not Saturday)Cells[4](Thursday) in the final week isnil, which forces theif day.After(today) { break }branch onhandler.go:200-201to executebuildHeatmapWeekstests usednow = 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 hits2346c366)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 PASSmake coverage—check-coverage: OK — zero uncovered statement blocksgolangci-lint run ./internal/stats/...— 0 issuesCloses bead bookshelf-q9sg on merge.
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>a1f6752be13231944f9cCode 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 theday.After(today)break athandler.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. Gotime.Weekday()= 3 (Sunday=0). Confirmed with Python.Cells[4]= Thursday 2024-06-13, which is aftertoday(2024-06-12).handler.go:200fires befored=4, leavingCells[4]as its zero value (nil pointer).Expect(last.Cells[4]).To(BeNil())directly asserts this. Not a tautology.Determinism:
nowistime.Date(2024, 6, 12, 12, 0, 0, 0, time.UTC)— a fixed constant, notime.Now(). Coverage is date-independent and will not flake.Ginkgo conventions:
var (weeks []heatmapWeek)declared at top ofDescribeblock.JustBeforeEach, assertion inIt.ExpectperIt.nowdeclared insideJustBeforeEach(not a varying dep acrossContextblocks, so no separateBeforeEachneeded). Acceptable.Coverage gate:
scripts/check-coverage.shunchanged. No exclusions added.No findings.
REVIEW VERDICT: 0 blocker, 0 major, 0 minor