MCPcopy Create free account
hub / github.com/Cawlumm/lyftr / TestCreateProgram_setNumberNormalized

Function TestCreateProgram_setNumberNormalized

backend/controllers/programs_test.go:189–220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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
206func 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 },

Callers

nothing calls this directly

Calls 6

setupTestDBFunction · 0.85
createTestUserFunction · 0.85
createTestExerciseFunction · 0.85
newContextFunction · 0.85
decodeResponseFunction · 0.85
CreateProgramMethod · 0.80

Tested by

no test coverage detected