Skip to content

test:added route_search and spatial_index tests#711

Open
Chamikajaya wants to merge 1 commit intoOneBusAway:mainfrom
Chamikajaya:fix/issue-697-implement-tests-route-search-spatial-idx
Open

test:added route_search and spatial_index tests#711
Chamikajaya wants to merge 1 commit intoOneBusAway:mainfrom
Chamikajaya:fix/issue-697-implement-tests-route-search-spatial-idx

Conversation

@Chamikajaya
Copy link

Summary

Adds unit tests for two previously untested modules: route_search.go and spatial_index.go in internal/gtfs/.

Closes #697

Changes

internal/gtfs/route_search_test.go (new)

  • TestBuildRouteSearchQuery — 12-case table-driven test for the FTS5 query builder covering: single/multi-word input, empty/whitespace, special characters (!, @, /), unicode (café, 日本), embedded double-quotes, and extra whitespace.
  • TestSearchRoutes_MatchingResults — integration test using RABA fixture data, verifies matching routes are returned.
  • TestSearchRoutes_NoMatch — verifies empty result for non-matching input.
  • TestSearchRoutes_EmptyInput — verifies empty string short-circuits to empty slice.
  • TestSearchRoutes_WhitespaceOnlyInput — verifies whitespace-only input short-circuits.
  • TestSearchRoutes_DefaultLimit — verifies maxCount=0 falls back to the default limit.

internal/gtfs/spatial_index_test.go (new)

  • TestQueryStopsInBounds — 6-case table-driven test: normal bounding box, no stops, all stops, zero-size (point query), extremely large bounds, and swapped min/max bounds.
  • TestQueryStopsInBounds_NilTree — verifies nil tree returns empty slice.
  • TestQueryStopsInBounds_EmptyTree — verifies empty tree returns no results.
  • TestBuildStopSpatialIndex_WithRABA — integration test using RABA fixture data, verifies the spatial index is populated with real stops.
  • TestMinMaxHelpers — 5-case table-driven test for the min/max helper functions.

Testing

  • No existing files were modified — only new test files were added.
  • All tests follow existing conventions: package gtfs, testify assertions, table-driven tests with t.Run, and the shared getSharedTestComponents singleton pattern.

Copilot AI review requested due to automatic review settings March 14, 2026 04:15
@CLAassistant
Copy link

CLAassistant commented Mar 14, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds test coverage for GTFS route full-text search and stop spatial indexing utilities in internal/gtfs/, addressing previously untested logic and edge cases (per #697).

Changes:

  • Adds table-driven unit tests for buildRouteSearchQuery and integration tests for Manager.SearchRoutes using RABA fixtures.
  • Adds table-driven unit tests for queryStopsInBounds (including normalization and edge cases) plus an integration test validating the built stop spatial index.
  • Adds direct tests for min/max helpers used by the spatial query normalization.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/gtfs/route_search_test.go New tests for FTS5 query building and route search behavior (match/no-match/empty/limit).
internal/gtfs/spatial_index_test.go New tests for R-tree bounds queries, nil/empty tree behavior, and spatial index population using fixtures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

name string
bounds utils.CoordinateBounds
expectedCount int
expectedIDs []string
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.

Add tests for route_search.go and spatial_index.go

3 participants