Skip to content

Add unit tests for DataCache — findNearby filtering and sorting #7

@GavT

Description

@GavT

Summary

DataCache.findNearby() is the critical data path — it filters permanently closed stations and sorts by distance. It has no tests.

What to test

File: backend/src/main/kotlin/uk/co/fueller/backend/DataCache.kt

Test Description
findNearby_excludesPermanentlyClosed Stations with status=PermanentlyClosed are excluded
findNearby_sortsByDistance Nearest station is first in result
findNearby_respectsRadiusLimit No station beyond radiusMiles appears in result
findNearby_emptyCache Returns empty list gracefully, no exception
findNearby_postcodeNotFound Invalid postcode returns empty list

Setup

Use a pre-populated in-memory ConcurrentHashMap fixture — no real API calls needed.

Workstream: WS2 Phase 2A

Metadata

Metadata

Assignees

No one assigned

    Labels

    WS2-testingWorkstream 2 – TestingtestingTest coverage task

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions