From e73b7a9ccb4bc61e54d1fdc61b5954879c637d00 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 25 Aug 2026 13:26:22 +0200 Subject: 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. --- web/server_test.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'web') 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", -- cgit v1.3