aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-08-25 13:26:22 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-08-25 13:26:22 +0200
commite73b7a9ccb4bc61e54d1fdc61b5954879c637d00 (patch)
tree34658a02faee971fa041a3f02160770ae283a6de /web
parentd5de3a6fefbc57bccfb1fe688f9c190ccf87d58d (diff)
Migrate cross-package ride test fixtures to the ridetest DSL
Replace raw FromColumns 4-array blocks in official_climb, mountain_pass and web test rides with ridetest.MustRide strings. Add a Heading option to ridetest for routes whose points are spaced differently per kilometer (e.g. the mountain_pass expanded-bounds route at 0.1 degrees/km). Lap, direction and cluster tests in official_climb keep FromColumns: the DSL generates monotonic northeast coords and cannot express per-point loops or reversals.
Diffstat (limited to 'web')
-rw-r--r--web/server_test.go22
1 files changed, 4 insertions, 18 deletions
diff --git a/web/server_test.go b/web/server_test.go
index 9ee578e..6a1c13f 100644
--- a/web/server_test.go
+++ b/web/server_test.go
@@ -17,6 +17,7 @@ import (
"github.com/jftuga/geodist"
"github.com/martinlehoux/biking_home/config"
"github.com/martinlehoux/biking_home/internal/dbtest"
+ "github.com/martinlehoux/biking_home/internal/ridetest"
"github.com/martinlehoux/biking_home/mountain_pass"
"github.com/martinlehoux/biking_home/official_climb"
"github.com/martinlehoux/biking_home/ride"
@@ -197,12 +198,7 @@ func TestHandlerRendersRideDetailWithEmbeddedRoute(t *testing.T) {
}
func TestBuildRideProfileIncludesClimbsAndCrossings(t *testing.T) {
- parsed := ride.FromColumns(
- []float64{0, 1000, 2000},
- []float64{300, 447, 380},
- []geodist.Coord{{Lat: 43.61, Lon: 5.42}, {Lat: 43.62, Lon: 5.43}, {Lat: 43.63, Lon: 5.44}},
- make([]time.Time, 3),
- )
+ parsed := ridetest.MustRide("1km at 14.7% | 1km at -6.7%", ridetest.StartCoord(43.61, 5.42), ridetest.StartElevation(300), ridetest.Sampling(1000))
passes := []mountain_pass.MountainPass{{
Name: "Pas de Magnan",
Elevation: 440,
@@ -225,12 +221,7 @@ func TestBuildRideProfileIncludesClimbsAndCrossings(t *testing.T) {
}
func TestBuildRideProfileIncludesOfficialClimbMatch(t *testing.T) {
- parsed := ride.FromColumns(
- []float64{0, 1000, 2000},
- []float64{300, 447, 380},
- []geodist.Coord{{Lat: 43.61, Lon: 5.42}, {Lat: 43.62, Lon: 5.43}, {Lat: 43.63, Lon: 5.44}},
- make([]time.Time, 3),
- )
+ parsed := ridetest.MustRide("1km at 14.7% | 1km at -6.7%", ridetest.StartCoord(43.61, 5.42), ridetest.StartElevation(300), ridetest.Sampling(1000))
profile := buildRideProfile(parsed, nil, []official_climb.OfficialClimb{{
ID: 42,
Name: "Col de Test",
@@ -247,12 +238,7 @@ func TestBuildRideProfileIncludesOfficialClimbMatch(t *testing.T) {
}
func TestBuildRideProfileUsesOfficialClimbBoundaries(t *testing.T) {
- parsed := ride.FromColumns(
- []float64{0, 1000, 2000},
- []float64{300, 447, 380},
- []geodist.Coord{{Lat: 43.61, Lon: 5.42}, {Lat: 43.62, Lon: 5.43}, {Lat: 43.6205, Lon: 5.4305}},
- make([]time.Time, 3),
- )
+ parsed := ridetest.MustRide("1km at 14.7% | 1km at -6.7%", ridetest.StartCoord(43.61, 5.42), ridetest.StartElevation(300), ridetest.Sampling(1000))
profile := buildRideProfile(parsed, nil, []official_climb.OfficialClimb{{
ID: 42,
Name: "Col de Test",