Skip to content

fix: TestArrivalsAndDeparturesForStop_VehicleWithNilID fails due to stale GetActiveServiceIDsForDate cache #764

@reddy-santhu

Description

@reddy-santhu

Summary

TestArrivalsAndDeparturesForStop_VehicleWithNilID in internal/restapi/arrivals_and_departures_for_stop_handler_test.go fails with no arrivals returned, causing the assertion:

should find arrival for test trip NilIDTrip

Root Cause

PR #744 introduced an in-memory cache for GetActiveServiceIDsForDate. Tests that insert their own calendar rows must call api.GtfsManager.MockClearServiceIDsCache() so the cache does not hold stale service IDs from an earlier test in the same package run.

This test inserts nilid_service via CreateCalendar but was missing that cache-clear call. When tests run in order (as in make test), nilid_service is never seen as active and the handler returns zero arrivals.

Fix

Add MockClearServiceIDsCache() after inserting the calendar entry — the same pattern already used in two other tests in this file.

How to verify

go test -tags "sqlite_fts5" -count=1 ./internal/restapi/...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions