- 08-01: GameDAGRouter edge cases and anchor validation TDD (17+ tests) - 08-02: Performance with large datasets (10K+ games) and diversity coverage TDD TDD discipline: tests define correctness, code must match. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4.8 KiB
phase, type
| phase | type |
|---|---|
| 08-dag-system-tdd | execute |
Purpose: Ensure the DAG routing algorithm handles boundary conditions correctly before testing at scale. Output: Comprehensive edge case test suite for GameDAGRouter, with code fixes if tests fail.
<execution_context> ~/.claude/get-shit-done/workflows/execute-phase.md ./summary.md ~/.claude/get-shit-done/references/tdd.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @SportsTime/Planning/Engine/GameDAGRouter.swift @SportsTimeTests/ScenarioBPlannerTests.swift Task 1: Create GameDAGRouterTests with edge case tests SportsTimeTests/GameDAGRouterTests.swift Create a new test file using Swift Testing framework (@Test attributes, #expect assertions).Include test helpers:
- makeStadium(id:city:lat:lon:) with default coordinates spread across US
- makeGame(id:stadiumId:startTime:) with default sport/teams
- date(_:) helper for "yyyy-MM-dd HH:mm" parsing
Write RED tests for these edge cases:
- Empty games array → returns empty routes
- Single game → returns game (unless anchor mismatch)
- Single game with non-matching anchor → returns []
- Two games, chronological and feasible → returns route containing both
- Two games, chronological but infeasible (too far) → returns two separate single-game routes
- Two games, reverse chronological (second before first) → returns two separate single-game routes
- Three games where only pairs are feasible → returns all valid pairs/singles
- Anchor game filtering: routes missing anchors are excluded
- Repeat cities OFF: routes with same city twice are excluded
- Repeat cities ON: routes with same city twice are included
Run tests expecting failures for any code gaps:
xcodebuild -project SportsTime.xcodeproj -scheme SportsTime -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.2' -only-testing:SportsTimeTests/GameDAGRouterTests test
Common fix areas:
- Edge case handling in findRoutes() lines 101-120
- canTransition() feasibility logic lines 463-507
- Anchor filtering logic lines 181-184
Do NOT change test expectations. If a test fails, the code is wrong.
xcodebuild -project SportsTime.xcodeproj -scheme SportsTime -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.2' -only-testing:SportsTimeTests/GameDAGRouterTests test
All tests pass All 10+ edge case tests pass (GREEN)
Task 3: Add canTransition boundary tests SportsTimeTests/GameDAGRouterTests.swift Add tests for canTransition edge cases via findRoutes() behavior:- Same stadium, same day, 4 hours apart → transition feasible
- Different stadium, 1000 miles apart, same day → infeasible (not enough driving time)
- Different stadium, 1000 miles apart, 2 days apart → feasible (enough driving days)
- Different stadium, 100 miles apart, 4 hours available → feasible
- Different stadium, 100 miles apart, 1 hour available → infeasible (need 3hr buffer after game)
- Game end buffer: 3hr buffer after game end before departure
- Arrival buffer: 1hr buffer before next game start
These test the canTransition() logic indirectly through findRoutes() results.
xcodebuild -project SportsTime.xcodeproj -scheme SportsTime -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.2' -only-testing:SportsTimeTests/GameDAGRouterTests test
All tests pass 7 additional boundary tests pass (17+ total tests)
Before declaring phase complete: - [ ] `xcodebuild test` for GameDAGRouterTests passes with 17+ tests - [ ] All edge cases documented in test names - [ ] No tests were modified to pass (code was fixed instead) - [ ] Existing tests in other test files still pass<success_criteria>
- All tasks completed
- All verification checks pass
- 17+ edge case tests for GameDAGRouter
- TDD discipline maintained (tests define correctness) </success_criteria>