refactor: add TripsForLocationResponse type and refactor tests to the new response model#916
refactor: add TripsForLocationResponse type and refactor tests to the new response model#916Ahmedhossamdev wants to merge 2 commits into
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughA new response type ChangesTrips-for-Location Handler Response & Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Performance Smoke Test ResultsStatus: PASSED
Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%. Full results uploaded as workflow artifact: k6-smoke-summary. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/restapi/trips_for_location_handler_test.go (1)
137-144: ⚡ Quick winTighten
includeSchedule=falseassertions to catch regressions.On Line 142, the current branch permits non-
nilentry.Scheduleas long asStopTimesis empty. That can miss accidental schedule payload leakage whenincludeSchedule=false. Assert schedule omission directly.Proposed test assertion adjustment
for _, entry := range model.Data.List { if tt.includeSchedule { if assert.NotNil(t, entry.Schedule, "schedule should be present when includeSchedule=true") { assert.NotEmpty(t, entry.Schedule.TimeZone) } - } else if entry.Schedule != nil { - assert.Empty(t, entry.Schedule.StopTimes, "stopTimes should be empty when includeSchedule=false") + } else { + assert.Nil(t, entry.Schedule, "schedule should be omitted when includeSchedule=false") } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/restapi/trips_for_location_handler_test.go` around lines 137 - 144, When tt.includeSchedule is false we should assert the schedule is omitted, not merely that StopTimes is empty; update the test loop over model.Data.List so that in the else branch you assert entry.Schedule is nil (e.g., use assert.Nil on entry.Schedule) rather than checking entry.Schedule.StopTimes, so any accidental schedule payload leakage when includeSchedule=false will fail the test (references: tt.includeSchedule, entry.Schedule, entry.Schedule.StopTimes, model.Data.List).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/restapi/trips_for_location_handler_test.go`:
- Around line 137-144: When tt.includeSchedule is false we should assert the
schedule is omitted, not merely that StopTimes is empty; update the test loop
over model.Data.List so that in the else branch you assert entry.Schedule is nil
(e.g., use assert.Nil on entry.Schedule) rather than checking
entry.Schedule.StopTimes, so any accidental schedule payload leakage when
includeSchedule=false will fail the test (references: tt.includeSchedule,
entry.Schedule, entry.Schedule.StopTimes, model.Data.List).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 11f4a12a-ce70-4434-8f19-ec197e30acef
📒 Files selected for processing (2)
internal/restapi/response_types.gointernal/restapi/trips_for_location_handler_test.go
Performance Smoke Test ResultsStatus: PASSED
Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%. Full results uploaded as workflow artifact: k6-smoke-summary. |
…ch the new response model
…cheduleInclusion for clarity
3f57de2 to
d870f3e
Compare
|
Performance Smoke Test ResultsStatus: PASSED
Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%. Full results uploaded as workflow artifact: k6-smoke-summary. |



Summary
TripsForLocationResponsealias and migrate all tests tocallAPIHandler[TripsForLocationResponse]map[string]anycasts in favor of typedmodel.Data.List/.ReferencesaccessMissingParameterstesttripsForLocationURLhelper to remove URL-building duplicationSummary by CodeRabbit