test: add E2E coverage for DUPLICATED real-time trips - #1298
Conversation
|
Warning Review limit reached
Next review available in: 6 minutes Limit details: You’ve used all 1 included review currently available under your plan. 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 (2)
📝 WalkthroughWalkthroughThis change adds end-to-end coverage for ChangesDUPLICATED real-time trip coverage
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
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 226-228: Update the assertions in the schedule stop-time loop of
the trip-for-route handler test to verify the exact expected combined stop IDs,
rather than merely checking for an underscore. Assert both expected agency/stop
ID combinations in schedule order.
🪄 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: b5b59c93-0de7-4ad6-97ef-f672c7f13a47
📒 Files selected for processing (1)
internal/restapi/trips_for_route_handler_test.go
Code reviewFound 1 issue:
maglev/internal/restapi/trips_for_route_handler_test.go Lines 238 to 252 in 00c17c0 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
aaronbrethorst
left a comment
There was a problem hiding this comment.
The schedule assertions in here are the good part — they genuinely cover the stripNumericSuffix fallback and confirm the suffixed trip keeps its own entry ID while carrying the base trip's stop times. The RT feed setup is correct too; InitGTFSManager does a synchronous first fetch, so there's no race to worry about.
One assertion doesn't do what its comment claims.
The references.trips block is tautological for the DUPLICATED path. In this fixture tfr-trip is an active scheduled trip, so it reaches references.trips through the ordinary static path — fetchedTrips → filteredRouteTrips → buildTripReferences(..., preFetchedTrips, ...) — fully populated. The handler's DUPLICATED-side resolution (if !filteredRouteTrips[baseTripID] { ... }, trips_for_route_handler.go:472-479) never executes, and deleting it entirely would leave this test green. The comment says the block verifies that stripNumericSuffix resolved the base trip, but that's covered by the schedule assertions instead.
Since base-trip reference resolution is one of the things #1297 specifically asked for, it's worth making real: make the base trip inactive at query time, or query at a moment when only the duplicated run is live, so the fallback branch is the only way the reference can appear.
The branch also conflicts with main, and more substantially than the conflict markers suggest: createTestApiWithTripsForRouteFixture no longer exists — it was replaced by a generic createTestApiWithGTFSFixture(t, clock, zipName, files map[string]string) plus per-scenario file maps. So your buildTripsForRouteFixtureZip extraction is largely redundant with what main now does more generally, and createTestApiWithTripsForRouteAndRealtime will want rebuilding on top of the new builder. Sorry — that landed while this was in the queue.
Two smaller notes for the rework: the URL only passes includeSchedule=true, so the DUPLICATED → ("DUPLICATED", "in_progress") status mapping is never exercised, which seems worth having in a PR with this title; and there's no assertion on list length, so a spurious extra entry would slip through.
Re-review whenever it's rebased.
… fixtures - Transition to createTestApiWithGTFSFixture after main rebase - Make base trip inactive at query time to strictly test the DUPLICATED fallback branch - Add synchronous SetRealTimeVehiclesForTest helper for clean injection - Add assertions for includeStatus phase mapping and list length
00c17c0 to
84131b7
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
burma-shave
left a comment
There was a problem hiding this comment.
merge in main and fix conflicts
aaronbrethorst
left a comment
There was a problem hiding this comment.
Approving on the merits — this looks good, but it can't merge as-is. See below.
All four points from my last review are addressed, and the important one is genuinely fixed. I checked it rather than assuming: at the 11:30 clock the base trip falls outside the handler's -30/+10 minute window, so it can only reach references.trips through the DUPLICATED fallback block — delete that block and the test fails. That's the difference from last time, when the assertion held no matter what the handler did.
The rest holds up too. dupEntry.Schedule would come back with empty stop IDs if stripNumericSuffix were removed, so the fallback is really exercised. ActiveTripID is set from the vehicle's own suffixed ID by BuildVehicleStatus, not the base ID, so that assertion has teeth. The DUPLICATED/in_progress pair matches GetVehicleStatusAndPhase, and require.Len(..., 2) guards against extra entries.
Two things stand between this and merging, neither of them the code:
- The branch conflicts with
main— it's one commit ahead and thirty-seven behind, and both files it touches have changed since. It needs another rebase. Sorry for the treadmill; that file is busy right now. - burma-shave has a change request still open on this PR. My approval doesn't clear that one, so please square it with them before merging.
While you're rebasing: the PR description still describes buildTripsForRouteFixtureZip and a mock GTFS-RT feed, neither of which exists in the current diff. Worth a refresh so the next reader isn't misled.
|
burma-shave
left a comment
There was a problem hiding this comment.
needs merge conflicts resolved again
|
@3rabiii checking in on this older PR. It is still blocked on merge conflicts from the last review. Could you please merge |



Description
This PR addresses end-to-end test coverage for the
DUPLICATEDreal-time trips path in thetrips-for-routehandler. It ensures that the handler correctly resolves base trips for duplicated vehicles using thestripNumericSuffixfallback and successfully populates the schedule and reference data.Changes Made
TestTripsForRouteHandler_DuplicatedRealtimeTripto verify that:DUPLICATEDfallback block.tripId.stripNumericSuffixworks correctly).ActiveTripIDis correctly set from the vehicle's own suffixed ID byBuildVehicleStatus, not the base ID.references.tripswith all associated static data.MockAddDuplicatedVehicle.Closes: #1297
Summary by CodeRabbit