test: add coverage for omitted and invalid time parameters - #1296
test: add coverage for omitted and invalid time parameters#12963rabiii wants to merge 2 commits into
Conversation
- Add TestTripsForRouteHandler_TimeOmitted to verify 200 OK fallback behavior. - Add TestTripsForRouteHandler_InvalidTimeParameter to assert 400 Bad Request on malformed inputs.
|
Warning Review limit reached
Next review available in: 23 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe change adds trips-for-route handler tests for omitted and invalid ChangesTrips-for-route time parameter coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/restapi/trips_for_route_handler_test.go`:
- Around line 219-230: Update the omitted-time parsing path in the
trips-for-route handler to use api.Clock instead of time.Now(), while preserving
explicit time-parameter behavior. Extend the test around
createTestApiWithTripsForRouteFixture and the omitted-time request to assert the
clock-dependent active fixture trip, and add coverage for each new
clock-selection branch or condition.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3d76fc8c-acb1-4db3-a31c-6c0954fdcc2b
📒 Files selected for processing (1)
internal/restapi/trips_for_route_handler_test.go
- Update utils.ParseTimeParameter and its callers to use the provided api.Clock instead of the system time.Now(). - Update TestTripsForRouteHandler_TimeOmitted with a strict assertion to guarantee the active fixture trip is deterministically returned.
|



Description
This PR addresses the missing test coverage for edge cases regarding the
timequery parameter in thetrips-for-routehandler.Changes Made
TestTripsForRouteHandler_TimeOmitted: Verifies that when thetimeparameter is not provided, the handler correctly defaults to the current clock time and returns a200 OKresponse.TestTripsForRouteHandler_InvalidTimeParameter: Asserts that passing malformed time values (e.g., garbage strings, overflowing epochs, or invalid calendar dates) correctly triggers a validation error, returning a400 Bad Request.Closes: #1295
Summary by CodeRabbit