Skip to content

test: add E2E coverage for DUPLICATED real-time trips - #1298

Open
3rabiii wants to merge 2 commits into
OneBusAway:mainfrom
3rabiii:fix-trips-for-route-gap13
Open

test: add E2E coverage for DUPLICATED real-time trips#1298
3rabiii wants to merge 2 commits into
OneBusAway:mainfrom
3rabiii:fix-trips-for-route-gap13

Conversation

@3rabiii

@3rabiii 3rabiii commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR addresses end-to-end test coverage for the DUPLICATED real-time trips path in the trips-for-route handler. It ensures that the handler correctly resolves base trips for duplicated vehicles using the stripNumericSuffix fallback and successfully populates the schedule and reference data.

Changes Made

  • Refactored Fixture Setup: Extracted buildTripsForRouteFixtureZip to allow reusing the synthetic GTFS static dataset across multiple tests.
  • Real-Time Mock Injection: Added createTestApiWithTripsForRouteAndRealtime to spin up a mock GTFS-RT feed serving a DUPLICATED vehicle with a suffixed trip ID (e.g., tfr-trip.00060), matching the Java-OBA format.
  • End-to-End Assertion: Added TestTripsForRouteHandler_DuplicatedRealtimeTrip to verify that:
    • The duplicated trip appears in the response list with its preserved combined suffixed tripId.
    • The schedule is successfully populated from the resolved base trip.
    • The resolved base trip correctly appears in references.trips with all associated static data (route, headsign, block).

Closes: #1297

Summary by CodeRabbit

  • Tests
    • Added integration coverage for duplicated real-time vehicle trips.
    • Verified that suffixed real-time trips correctly resolve their associated static schedules and references.
    • Improved test fixtures for synthetic transit data and real-time feeds.

- Refactor buildTripsForRouteFixtureZip for fixture reuse.
- Add createTestApiWithTripsForRouteAndRealtime to inject a DUPLICATED vehicle with a suffixed trip ID.
- Add TestTripsForRouteHandler_DuplicatedRealtimeTrip to assert base trip resolution and schedule population end-to-end.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@3rabiii, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3873083a-fa53-4b7e-9eca-cc04bff63a22

📥 Commits

Reviewing files that changed from the base of the PR and between 5b62599 and 00c17c0.

📒 Files selected for processing (1)
  • internal/restapi/trips_for_route_handler_test.go
📝 Walkthrough

Walkthrough

This change adds end-to-end test coverage for DUPLICATED real-time trips in trips-for-route. It extracts GTFS ZIP fixture creation into a helper, sets up a protobuf real-time feed in tests, and verifies suffixed duplicated trips resolve to their base static trip data and references.

Changes

DUPLICATED trip coverage

Layer / File(s) Summary
Reusable GTFS fixture preparation
internal/restapi/trips_for_route_handler_test.go
The test moves synthetic GTFS ZIP creation into buildTripsForRouteFixtureZip. The existing test API fixture setup now uses this helper.
DUPLICATED real-time trip integration test
internal/restapi/trips_for_route_handler_test.go
The test adds protobuf and HTTP test-server setup for a vehicle-position feed with a DUPLICATED trip. It verifies that static and suffixed trips appear in the response, and that the duplicated trip resolves the base schedule, combined stop IDs, route, headsign, and block references.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • OneBusAway/maglev#1224: This PR adds handler-level test coverage for the DUPLICATED real-time trip resolution that PR #1224 implemented in tripsForRouteHandler.
  • OneBusAway/maglev#1256: Both PRs change trips-for-route trip identity resolution and the related realtime integration-test fixtures.
  • OneBusAway/maglev#1288: Both PRs modify trips-for-route integration behavior and tests around referenced trip data.

Suggested reviewers: ahmedhossamdev

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the added end-to-end coverage for DUPLICATED real-time trips.
Linked Issues check ✅ Passed The test covers the suffixed trip ID, base-trip resolution, schedule population, and static references required by issue #1297.
Out of Scope Changes check ✅ Passed The fixture refactor and test dependencies directly support the requested end-to-end test and introduce no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@3rabiii

3rabiii commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8bed443 and 5b62599.

📒 Files selected for processing (1)
  • internal/restapi/trips_for_route_handler_test.go

Comment thread internal/restapi/trips_for_route_handler_test.go Outdated
- Replace the loose substring containment check with a strict, ordered slice equality assertion.
- Ensure the exact expected combined stop IDs are returned in the correct schedule order.
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing end-to-end test coverage for DUPLICATED real-time trips in trips-for-route

1 participant