Skip to content

fix: tighten terminal-distances spec mock to avoid station_terminal_distance substring collision #224

@GitAddRemote

Description

@GitAddRemote

User Story

As a developer maintaining the ETL spec, I want the DataSource query mock to match only the terminal code-lookup query so future SQL changes aren't accidentally masked by an overly broad string match.

Definition of Done

  • In `terminal-distances-sync.step.spec.ts`, the `buildDsQuery` branch that returns terminal rows is tightened from `sql.includes('station_terminal')` to a more specific match (e.g. `sql.includes('FROM station_terminal')` and `!sql.includes('station_terminal_distance')`) so it no longer matches INSERT/UPDATE queries against `station_terminal_distance`

Acceptance Criteria

  • The mock only fires for the `SELECT code, id FROM station_terminal` lookup
  • INSERT and UPDATE queries against `station_terminal_distance` are not matched by this branch

Technical Elaboration

Current match: `sql.includes('station_terminal')`

`station_terminal_distance` contains the substring `station_terminal`, so INSERT/UPDATE queries to the distance table would also hit this branch and return terminal-lookup rows, silently masking any SQL bug that touches both tables.

Fix: `sql.includes('FROM station_terminal') && !sql.includes('station_terminal_distance')`

File: `backend/src/modules/catalog-etl/steps/terminal-distances-sync.step.spec.ts`

Design Elaboration

Test-only change, no production code affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions