feat: add per-workout-type pace range and expected HR zone
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
45
backend/internal/store/workoutpaces_test.go
Normal file
45
backend/internal/store/workoutpaces_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWorkoutTypePaces_SeededOnePerKindThenUpdate(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
all, err := db.ListWorkoutTypePaces(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("ListWorkoutTypePaces: %v", err)
|
||||
}
|
||||
if len(all) != 7 {
|
||||
t.Fatalf("expected 7 seeded pace rows (one per taxonomy kind), got %d", len(all))
|
||||
}
|
||||
for _, p := range all {
|
||||
if p.PaceMinSecPerKm != nil || p.PaceMaxSecPerKm != nil || p.ExpectedHRZone != nil {
|
||||
t.Errorf("expected all-nil seeded pace row for kind %d, got %+v", p.WorkoutKindID, p)
|
||||
}
|
||||
}
|
||||
|
||||
target := all[0]
|
||||
minPace, maxPace, zone := 330.0, 420.0, 2
|
||||
target.PaceMinSecPerKm = &minPace
|
||||
target.PaceMaxSecPerKm = &maxPace
|
||||
target.ExpectedHRZone = &zone
|
||||
|
||||
if err := db.UpdateWorkoutTypePace(ctx, target); err != nil {
|
||||
t.Fatalf("UpdateWorkoutTypePace: %v", err)
|
||||
}
|
||||
|
||||
got, err := db.GetWorkoutTypePace(ctx, target.WorkoutKindID)
|
||||
if err != nil {
|
||||
t.Fatalf("GetWorkoutTypePace: %v", err)
|
||||
}
|
||||
if got.PaceMinSecPerKm == nil || *got.PaceMinSecPerKm != 330 {
|
||||
t.Errorf("PaceMinSecPerKm = %v, want 330", got.PaceMinSecPerKm)
|
||||
}
|
||||
if got.ExpectedHRZone == nil || *got.ExpectedHRZone != 2 {
|
||||
t.Errorf("ExpectedHRZone = %v, want 2", got.ExpectedHRZone)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user