Skip to content

test: add E2E coverage for status sub-object fields - #1300

Open
3rabiii wants to merge 1 commit into
OneBusAway:mainfrom
3rabiii:fix-trips-for-route-gap14
Open

test: add E2E coverage for status sub-object fields#1300
3rabiii wants to merge 1 commit into
OneBusAway:mainfrom
3rabiii:fix-trips-for-route-gap14

Conversation

@3rabiii

@3rabiii 3rabiii commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR addresses Issue 16 by adding strict end-to-end test coverage for the status sub-object fields in the trips-for-route API response. It ensures that the schema adheres to the defined specifications and prevents potential frontend crashes caused by unexpected null values or missing fields.

Changes Made

  • Fixture Refactoring: Extracted buildTripsForRouteFixtureZip to reuse the synthetic GTFS static dataset across multiple API test builders.
  • Real-Time Mock Injection: Added the createTestApiWithScheduledRealtimePosition helper to inject a SCHEDULED vehicle tracking the fixture trip with valid GPS coordinates. (Named uniquely to prevent merge conflicts with other real-time test setups).
  • Strict Assertions: Added TestTripsForRouteHandler_StatusFields to verify:
    • blockTripSequence is a non-negative integer.
    • position.lat and position.lon are accurately populated (handling the GTFS-RT float32 to Go float64 conversion).
    • occupancyCount correctly returns the -1 sentinel value when the feed omits occupancy data.
    • situationIds and vehicleFeatures are strictly non-nil empty slices ([]).

Closes: #1299

Summary by CodeRabbit

  • Tests
    • Expanded coverage for trip status information returned by the API.
    • Validates vehicle positions, block sequencing, occupancy values, and related service details.
    • Adds realistic transit feed scenarios to improve confidence in trip and vehicle-status results.

- Extract buildTripsForRouteFixtureZip to reuse the static GTFS fixture.
- Add createTestApiWithScheduledRealtimePosition to inject a SCHEDULED vehicle with valid GPS coordinates.
- Add TestTripsForRouteHandler_StatusFields to strictly assert blockTripSequence, lat/lon conversion, occupancyCount sentinel, and non-nil situationIds/vehicleFeatures.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b2a53bd6-0a51-46a6-9e75-cd2f7d880d50

📥 Commits

Reviewing files that changed from the base of the PR and between 8bed443 and 9805ac4.

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

📝 Walkthrough

Walkthrough

The test suite adds reusable GTFS and GTFS-RT fixtures for trips-for-route. It verifies realtime coordinates, block sequence, occupancy sentinel handling, and non-nil empty status slices.

Changes

Trips-for-route status coverage

Layer / File(s) Summary
Build reusable realtime test fixtures
internal/restapi/trips_for_route_handler_test.go
The test setup adds GTFS-RT imports, realtime coordinates, and a reusable GTFS ZIP builder.
Exercise realtime status fields
internal/restapi/trips_for_route_handler_test.go
A scheduled vehicle-position feed is served through an HTTP test server. The new test checks block sequence, GPS coordinates, occupancy -1, and non-nil empty situationIds and vehicleFeatures slices.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related issues

  • Issue 1299: Directly requests coverage for the status fields asserted by this test.
  • Issue 1292: Adds overlapping trips-for-route status-field test coverage.

Possibly related PRs

Suggested reviewers: ahmedhossamdev, aaronbrethorst

🚥 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 describes the added end-to-end test coverage for status sub-object fields.
Linked Issues check ✅ Passed The test covers all requirements in issue #1299, including block sequence, position, occupancy sentinel, and non-null empty arrays.
Out of Scope Changes check ✅ Passed The fixture refactor and scheduled vehicle-position helper directly support the requested real-time status-field coverage.
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.

@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 test coverage for status sub-object fields in trips-for-route

1 participant