diff --git a/internal/restapi/arrivals_and_departures_for_stop_handler_test.go b/internal/restapi/arrivals_and_departures_for_stop_handler_test.go index b9781af4..f63d084a 100644 --- a/internal/restapi/arrivals_and_departures_for_stop_handler_test.go +++ b/internal/restapi/arrivals_and_departures_for_stop_handler_test.go @@ -1235,12 +1235,11 @@ func TestArrivalsAndDeparturesForStop_VehicleWithNilID(t *testing.T) { api := createTestApiWithClock(t, mockClock) defer api.Shutdown() t.Cleanup(api.GtfsManager.MockResetRealTimeData) - // Clear the service-IDs cache so that the calendar inserted below is visible, - // even if a previous test already cached the result for this date. - api.GtfsManager.MockClearServiceIDsCache() + // Ensure cache is cleared before test runs + api.GtfsManager.MockClearServiceIDsCache() - // Clear the service-IDs cache so the request sees the newly inserted calendar entry - api.GtfsManager.MockClearServiceIDsCache() + // Also clean up after test + t.Cleanup(api.GtfsManager.MockClearServiceIDsCache) ctx := context.Background() queries := api.GtfsManager.GtfsDB.Queries @@ -1289,6 +1288,10 @@ func TestArrivalsAndDeparturesForStop_VehicleWithNilID(t *testing.T) { }) require.NoError(t, err) + // Clear the service-IDs cache so the upcoming request sees the newly inserted + // calendar entry rather than a result cached by an earlier test in this package. + api.GtfsManager.MockClearServiceIDsCache() + _, err = queries.CreateTrip(ctx, gtfsdb.CreateTripParams{ ID: tripID, RouteID: routeID, diff --git a/internal/restapi/block_sequence_helper.go b/internal/restapi/block_sequence_helper.go index 47760d5c..2696f897 100644 --- a/internal/restapi/block_sequence_helper.go +++ b/internal/restapi/block_sequence_helper.go @@ -17,7 +17,7 @@ func (api *RestAPI) getBlockSequenceForStopSequence(ctx context.Context, tripID blockTrips, err := api.GtfsManager.GtfsDB.Queries.GetTripsByBlockID(ctx, blockID) if err != nil { - return 0 + return stopSequence } type TripWithDetails struct { diff --git a/internal/restapi/schedule_for_route_handler.go b/internal/restapi/schedule_for_route_handler.go index 2f6e117c..101a0fd6 100644 --- a/internal/restapi/schedule_for_route_handler.go +++ b/internal/restapi/schedule_for_route_handler.go @@ -254,8 +254,8 @@ func (api *RestAPI) scheduleForRouteHandler(w http.ResponseWriter, r *http.Reque combinedTripID := utils.FormCombinedID(agencyID, t.ID) tripRef := models.NewTripReference( combinedTripID, - t.RouteID, - t.ServiceID, + utils.FormCombinedID(agencyID, t.RouteID), + utils.FormCombinedID(agencyID, t.ServiceID), t.TripHeadsign.String, t.TripShortName.String, strconv.FormatInt(t.DirectionID.Int64, 10),