fix: PR comments #70
No reviewers
Labels
No labels
bug
ci
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
performance
priority
P0
priority
P1
priority
P2
question
refactor
size
L
size
M
size
S
size
XL
size
XS
tests
trivial
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
noe.trevino/paso!70
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/calendar"
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?
PR Summary (auto-generated)
NextMonth()andPrevMonth()into a singlenavigateMonth(delta int)helper functiontime.Date()automatic normalization instead of manual boundary checks (month 13 → January next year, month 0 → December previous year)cursorWantpreserves the user's desired day position (e.g., day 31) when navigating through months with fewer days@ -860,0 +930,4 @@cursorWant: tt.startDay,}state.navigateMonth(tt.delta)Testing a private method (
navigateMonth) is a code smell. Tests should verify behavior through public APIs (NextMonth(),PrevMonth()). Private methods are implementation details that should be covered indirectly through their callers.This creates brittle tests that break when refactoring internals, and makes it harder to change the implementation later.
@ -860,0 +946,4 @@}})}}This test function duplicates the exact same test structure and logic as
TestNavigateMonth_NegativeDelta,TestNavigateMonth_DayClamping,TestNavigateMonth_PreservesCursorWant,TestNavigateMonth_YearBoundaries, andTestNavigateMonth_ZeroDelta.DRY violation: The test execution logic (lines 924-948) is copy-pasted 6 times. Extract to a helper:
Then each test function just defines its cases and calls the helper.
@ -860,0 +868,4 @@expectedYear intexpectedMonth time.MonthexpectedDay int}{The test struct is duplicated across 5 different test functions with identical fields. This violates DRY—define it once at package level:
@ -860,0 +943,4 @@}if state.cursorWant != tt.startDay {t.Errorf("cursorWant should remain %d, got %d", tt.startDay, state.cursorWant)}Assertion logic duplicated across all 6
TestNavigateMonth_*functions. These 12 lines are copy-pasted repeatedly—extract to a helper:@ -860,0 +878,4 @@expectedYear: 2024,expectedMonth: time.February,expectedDay: 15,},Test case duplication: This "forward 1 month" test is semantically equivalent to existing tests like
TestNextMonth_BasicForward(which likely exists for the public API). These tests through the private method add no value beyond what testingNextMonth()already provides.@ -860,0 +908,4 @@expectedYear: 2026,expectedMonth: time.March,expectedDay: 10,},These cases test
navigateMonthwith deltas >1 (3, 12, 24 months). However, the public API (NextMonth/PrevMonth) only uses delta=±1. Testing with arbitrary deltas tests functionality that's never actually used.If multi-month navigation is needed, expose it through the public API first. Otherwise, remove these cases.