Skip to content

refactor(tests): shape handler tests and add ShapeEntryResponse type#956

Open
Ahmedhossamdev wants to merge 1 commit into
mainfrom
refactor/typed-shapes-tests
Open

refactor(tests): shape handler tests and add ShapeEntryResponse type#956
Ahmedhossamdev wants to merge 1 commit into
mainfrom
refactor/typed-shapes-tests

Conversation

@Ahmedhossamdev
Copy link
Copy Markdown
Member

@Ahmedhossamdev Ahmedhossamdev commented May 16, 2026

Update the shapes-tests to use new response type models for parsing the JSON responses.

Summary by CodeRabbit

  • Chores
    • Internal improvements to test infrastructure and response handling mechanisms.

Review Change Stack

@Ahmedhossamdev Ahmedhossamdev requested a review from fletcherw May 16, 2026 22:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 43f5f30d-6aa1-4a75-9d5c-f339f17f0af9

📥 Commits

Reviewing files that changed from the base of the PR and between 2f29632 and b552a1f.

📒 Files selected for processing (2)
  • internal/restapi/response_types.go
  • internal/restapi/shapes_handler_test.go

📝 Walkthrough

Walkthrough

This PR adds a new typed response alias ShapeEntryResponse and refactors shape handler tests to use it. The test suite is reorganized with typed helpers, consolidated setup logic, and unified validation patterns covering end-to-end behavior, ID validation, polyline decoding across sequences, and ordering assertions.

Changes

Shape Response Type and Handler Tests Refactor

Layer / File(s) Summary
ShapeEntryResponse type alias
internal/restapi/response_types.go
Added ShapeEntryResponse as a typed alias for EntryResponse[models.ShapeEntry].
Test helpers and polyline decoding utilities
internal/restapi/shapes_handler_test.go
Introduced shapePoint struct, shapeURL helper with fixed API key, updated setupShapeTest to accept typed points and return combined IDs, and added decodePolylinePoints utility for centralized polyline decoding using polyline.DecodeCoords.
Shape handler tests refactored with new infrastructure
internal/restapi/shapes_handler_test.go
Reorganized test suite using callAPIHandler with ShapeEntryResponse; replaced 10 separate test functions with consolidated patterns: single end-to-end assertion test, table-driven ID validation test, parameterized polyline decoding subtest covering looping/out-and-back/duplicate-point sequences, and updated sequence ordering validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • OneBusAway/maglev#897: Introduces typed RoutesResponse alias and refactors routes handler tests similarly using callAPIHandler[...] with the new type.
  • OneBusAway/maglev#913: Adds typed EntryResponse[...] aliases and refactors handler tests to use callAPIHandler[<typed alias>] for direct field assertions.

Suggested reviewers

  • fletcherw
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses both main changes: refactoring shape handler tests and adding the ShapeEntryResponse type. It is specific, concise, and clearly summarizes the primary changes in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/typed-shapes-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 1.8 ms
Error rate 0.00%
Total requests 344
Req/sec 11.3

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

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.

1 participant