aboutsummaryrefslogtreecommitdiff
path: root/web/official-climbs_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'web/official-climbs_test.go')
-rw-r--r--web/official-climbs_test.go28
1 files changed, 1 insertions, 27 deletions
diff --git a/web/official-climbs_test.go b/web/official-climbs_test.go
index ba71f19..8fab49c 100644
--- a/web/official-climbs_test.go
+++ b/web/official-climbs_test.go
@@ -18,7 +18,7 @@ var testRideStart = time.Date(2026, 9, 1, 8, 0, 0, 0, time.UTC)
func testRideForClimb(t *testing.T) (ride.Ride, official_climb.OfficialClimb) {
t.Helper()
parsed := ridetest.MustRide("1km at 14.7% | 1km at -6.7%", ridetest.StartCoord(43.61, 5.42), ridetest.StartElevation(300), ridetest.Sampling(1000), ridetest.StartTime(testRideStart))
- return parsed, official_climb.OfficialClimb{Name: "Col de Test", StartCoord: parsed.Coords[0], EndCoord: parsed.Coords[1]}
+ return parsed, official_climb.OfficialClimb{Name: "Col de Test", StartCoord: parsed.Coords[0], EndCoord: parsed.Coords[1], Sample: parsed.Sample(0, 1)}
}
func insertTestRide(t *testing.T, db *sql.DB) int64 {
@@ -33,32 +33,6 @@ func insertTestRide(t *testing.T, db *sql.DB) int64 {
return id
}
-func TestAttemptsFromAnalysisSnapshotsOfficialClimbs(t *testing.T) {
- parsed, climb := testRideForClimb(t)
- analysis := rideanalysis.Analyze(parsed, nil, []official_climb.OfficialClimb{{ID: 42, Name: climb.Name, StartCoord: climb.StartCoord, EndCoord: climb.EndCoord}}, official_climb.DefaultMatchPolicy())
-
- attempts := attemptsFromAnalysis(7, analysis, parsed)
- require.Len(t, attempts, 1)
- assert.Equal(t, int64(7), attempts[0].RideID)
- assert.Equal(t, int64(42), attempts[0].ClimbID)
- assert.Equal(t, 0, attempts[0].Occurrence)
- assert.InDelta(t, 1000, attempts[0].DistanceM, 1)
- assert.InDelta(t, 147, attempts[0].ElevationGainM, 1)
- assert.InDelta(t, 14.7, attempts[0].SlopePercent, 0.1)
- assert.Positive(t, attempts[0].Cotacol)
- assert.Equal(t, "v1", attempts[0].CotacolAlgoVersion)
- assert.Equal(t, testRideStart, attempts[0].StartedAt.UTC())
- assert.False(t, attempts[0].EndedAt.IsZero(), "attempt end must come from ride timestamps")
-}
-
-func TestAttemptsFromAnalysisSkipsUnmatchedClimbs(t *testing.T) {
- parsed, _ := testRideForClimb(t)
- analysis := rideanalysis.Analyze(parsed, nil, nil, official_climb.DefaultMatchPolicy())
-
- attempts := attemptsFromAnalysis(7, analysis, parsed)
- assert.Empty(t, attempts)
-}
-
func TestRecordOfficialClimbAttemptsPersistsAndReplaces(t *testing.T) {
server, db := newWebTestServer(t)
rideID := insertTestRide(t, db)