refactor: merge internal/sync into internal/garmin, regroup api files and routes
Garmin auth/sync routes move under /api/garmin/*; sync.Service becomes garmin.Sync with garmin.SyncConfig/ClientConfig; applog becomes internal/log; the test mock moves into the garmin package as MockClient (breaking the test-only import cycle the merge created); stale test URLs and type names updated to match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,8 +37,8 @@ missing" from "not yet fetched."
|
||||
### Task 1: `wrapper.py` marks a 404 with `not_found: true`
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/internal/garmin/pyscript/wrapper.py` (imports, `dispatch`)
|
||||
- Modify: `backend/internal/garmin/pyscript/tests/test_wrapper.py` (new test)
|
||||
- Modify: `../../../backend/internal/garmin/wrapper/wrapper.py` (imports, `dispatch`)
|
||||
- Modify: `../../../backend/internal/garmin/wrapper/tests/test_wrapper.py` (new test)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `garminconnect.GarminConnectNotFoundError` (already installed as a dependency).
|
||||
@@ -48,7 +48,7 @@ missing" from "not yet fetched."
|
||||
|
||||
- [ ] **Step 1: Write the failing test**
|
||||
|
||||
Add to `backend/internal/garmin/pyscript/tests/test_wrapper.py`:
|
||||
Add to `../../../backend/internal/garmin/wrapper/tests/test_wrapper.py`:
|
||||
|
||||
```python
|
||||
def test_call_marks_not_found_error_specifically():
|
||||
@@ -77,14 +77,14 @@ def test_call_does_not_mark_other_errors_as_not_found():
|
||||
|
||||
Run: `cd backend/internal/garmin/pyscript && python3 -m pytest tests/test_wrapper.py -k not_found -v`
|
||||
(use whatever Python interpreter this repo's wrapper tests normally run under -- see
|
||||
`backend/internal/garmin/pyscript/.venv` if one exists, or the `GARMIN_WRAPPER_PYTHON` convention).
|
||||
`../../../backend/internal/garmin/wrapper/.venv` if one exists, or the `GARMIN_WRAPPER_PYTHON` convention).
|
||||
Expected: `test_call_marks_not_found_error_specifically` FAILS (`resp` has no `"not_found"` key
|
||||
yet); `test_call_does_not_mark_other_errors_as_not_found` already passes (nothing to change for
|
||||
that case).
|
||||
|
||||
- [ ] **Step 3: Update `dispatch()`**
|
||||
|
||||
In `backend/internal/garmin/pyscript/wrapper.py`, replace:
|
||||
In `../../../backend/internal/garmin/wrapper/wrapper.py`, replace:
|
||||
|
||||
```python
|
||||
from garminconnect import Garmin
|
||||
@@ -144,7 +144,7 @@ Expected: all tests PASS, including both new ones and every existing test unchan
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/internal/garmin/pyscript/wrapper.py backend/internal/garmin/pyscript/tests/test_wrapper.py
|
||||
git add backend/internal/garmin/wrapper/wrapper.py backend/internal/garmin/wrapper/tests/test_wrapper.py
|
||||
git commit -m "$(cat <<'EOF'
|
||||
feat(garmin): mark a wrapper 404 with not_found in the error response
|
||||
|
||||
@@ -659,8 +659,8 @@ EOF
|
||||
### Task 4: `fillPendingWorkouts` stops retrying a confirmed 404
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/internal/sync/service.go` (`fillPendingWorkouts`)
|
||||
- Modify: `backend/internal/sync/service_test.go` (new test)
|
||||
- Modify: `../../../backend/internal/garmin/sync.go` (`fillPendingWorkouts`)
|
||||
- Modify: `../../../backend/internal/garmin/sync_test.go` (new test)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `garmin.ErrNotFound` (Task 2), `db.SetActivityWorkoutNotFound` (Task 3).
|
||||
@@ -668,7 +668,7 @@ EOF
|
||||
|
||||
- [ ] **Step 1: Write the failing test**
|
||||
|
||||
Add to `backend/internal/sync/service_test.go`, right after
|
||||
Add to `../../../backend/internal/garmin/sync_test.go`, right after
|
||||
`TestFillPendingDetails_OneWorkoutFetchFailureDoesNotAbortTheWorkoutsPass`:
|
||||
|
||||
```go
|
||||
@@ -743,7 +743,7 @@ regardless of the error's nature).
|
||||
|
||||
- [ ] **Step 3: Update `fillPendingWorkouts`**
|
||||
|
||||
In `backend/internal/sync/service.go`, replace:
|
||||
In `../../../backend/internal/garmin/sync.go`, replace:
|
||||
|
||||
```go
|
||||
for i, a := range pending {
|
||||
@@ -794,7 +794,7 @@ with:
|
||||
}
|
||||
```
|
||||
|
||||
Add `"errors"` to `service.go`'s import block.
|
||||
Add `"errors"` to `sync.go`'s import block.
|
||||
|
||||
- [ ] **Step 4: Run the test to verify it passes**
|
||||
|
||||
@@ -817,7 +817,7 @@ Expected: all pass, `gofmt -l .` prints nothing.
|
||||
- [ ] **Step 7: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/internal/sync/service.go backend/internal/sync/service_test.go
|
||||
git add backend/internal/sync/sync.go backend/internal/sync/sync_test.go
|
||||
git commit -m "$(cat <<'EOF'
|
||||
fix(sync): stop retrying a workout Garmin confirms is gone
|
||||
|
||||
|
||||
Reference in New Issue
Block a user