(t *testing.T)
| 187 | |
| 188 | if w.Code != http.StatusOK { |
| 189 | t.Fatalf("expected 200, got %d: %s", w.Code, w.Body.String()) |
| 190 | } |
| 191 | |
| 192 | // Old exercise should be gone |
| 193 | var count int |
| 194 | db.DB.QueryRow(`SELECT COUNT(*) FROM program_exercises WHERE program_id = ? AND exercise_id = ?`, pid, exID).Scan(&count) |
| 195 | if count != 0 { |
| 196 | t.Error("old exercise not removed after update") |
| 197 | } |
| 198 | |
| 199 | // New exercise should exist |
| 200 | db.DB.QueryRow(`SELECT COUNT(*) FROM program_exercises WHERE program_id = ? AND exercise_id = ?`, pid, exID2).Scan(&count) |
| 201 | if count != 1 { |
| 202 | t.Error("new exercise not found after update") |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | func TestCreateProgram_setNumberNormalized(t *testing.T) { |
| 207 | setupTestDB(t) |
| 208 | uid := createTestUser(t) |
| 209 | exID := createTestExercise(t) |
| 210 | |
| 211 | // Send set_number: 0 — backend should normalize to 1 |
| 212 | body := map[string]any{ |
| 213 | "name": "Norm Test", |
| 214 | "days": []map[string]any{ |
| 215 | { |
| 216 | "is_rest_day": false, |
| 217 | "exercises": []map[string]any{ |
| 218 | { |
| 219 | "exercise_id": exID, |
| 220 | "sets": []map[string]any{{"set_number": 0, "target_reps": 10, "target_weight": 50.0}}, |
| 221 | }, |
| 222 | }, |
| 223 | }, |
nothing calls this directly
no test coverage detected