diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-25 13:26:22 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-25 13:26:22 +0200 |
| commit | e73b7a9ccb4bc61e54d1fdc61b5954879c637d00 (patch) | |
| tree | 34658a02faee971fa041a3f02160770ae283a6de /official_climb/official_climb_test.go | |
| parent | d5de3a6fefbc57bccfb1fe688f9c190ccf87d58d (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 'official_climb/official_climb_test.go')
| -rw-r--r-- | official_climb/official_climb_test.go | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/official_climb/official_climb_test.go b/official_climb/official_climb_test.go index bd59efc..ed121e5 100644 --- a/official_climb/official_climb_test.go +++ b/official_climb/official_climb_test.go @@ -6,6 +6,7 @@ import ( "github.com/jftuga/geodist" "github.com/martinlehoux/biking_home/internal/dbtest" + "github.com/martinlehoux/biking_home/internal/ridetest" "github.com/martinlehoux/biking_home/official_climb" "github.com/martinlehoux/biking_home/ride" "github.com/stretchr/testify/assert" @@ -52,17 +53,7 @@ func TestMatchPolicyRejectsInvalidRadius(t *testing.T) { } func TestMatchClimbMatchesWithoutDetectedClimb(t *testing.T) { - parsed := ride.FromColumns( - []float64{0, 1000, 2000, 3000}, - []float64{100, 150, 200, 100}, - []geodist.Coord{ - {Lat: 43.10, Lon: 5.10}, - {Lat: 43.11, Lon: 5.11}, - {Lat: 43.12, Lon: 5.12}, - {Lat: 43.13, Lon: 5.13}, - }, - []time.Time{time.Unix(0, 0), time.Unix(60, 0), time.Unix(120, 0), time.Unix(180, 0)}, - ) + parsed := ridetest.MustRide("2km at 5% | 1km at -10%", ridetest.StartCoord(43.10, 5.10), ridetest.StartElevation(100), ridetest.Sampling(1000)) official := official_climb.OfficialClimb{ Name: "On route", StartCoord: parsed.Coords()[1], @@ -75,17 +66,7 @@ func TestMatchClimbMatchesWithoutDetectedClimb(t *testing.T) { } func TestMatchClimbMatchesEndpointInsideRadius(t *testing.T) { - parsed := ride.FromColumns( - []float64{0, 1000, 2000, 3000}, - []float64{100, 150, 200, 100}, - []geodist.Coord{ - {Lat: 43.10, Lon: 5.10}, - {Lat: 43.11, Lon: 5.11}, - {Lat: 43.12, Lon: 5.12}, - {Lat: 43.13, Lon: 5.13}, - }, - []time.Time{time.Unix(0, 0), time.Unix(60, 0), time.Unix(120, 0), time.Unix(180, 0)}, - ) + parsed := ridetest.MustRide("2km at 5% | 1km at -10%", ridetest.StartCoord(43.10, 5.10), ridetest.StartElevation(100), ridetest.Sampling(1000)) official := official_climb.OfficialClimb{ Name: "Offset from route", StartCoord: geodist.Coord{Lat: 43.1101, Lon: 5.1101}, @@ -98,17 +79,7 @@ func TestMatchClimbMatchesEndpointInsideRadius(t *testing.T) { } func TestMatchClimbRejectsReversedEndpoints(t *testing.T) { - parsed := ride.FromColumns( - []float64{0, 1000, 2000, 3000}, - []float64{100, 150, 200, 100}, - []geodist.Coord{ - {Lat: 43.10, Lon: 5.10}, - {Lat: 43.11, Lon: 5.11}, - {Lat: 43.12, Lon: 5.12}, - {Lat: 43.13, Lon: 5.13}, - }, - []time.Time{time.Unix(0, 0), time.Unix(60, 0), time.Unix(120, 0), time.Unix(180, 0)}, - ) + parsed := ridetest.MustRide("2km at 5% | 1km at -10%", ridetest.StartCoord(43.10, 5.10), ridetest.StartElevation(100), ridetest.Sampling(1000)) official := official_climb.OfficialClimb{ Name: "Reversed", StartCoord: parsed.Coords()[2], @@ -119,17 +90,7 @@ func TestMatchClimbRejectsReversedEndpoints(t *testing.T) { } func TestMatchClimbRejectsEndpointOutsideRadius(t *testing.T) { - parsed := ride.FromColumns( - []float64{0, 1000, 2000, 3000}, - []float64{100, 150, 200, 100}, - []geodist.Coord{ - {Lat: 43.10, Lon: 5.10}, - {Lat: 43.11, Lon: 5.11}, - {Lat: 43.12, Lon: 5.12}, - {Lat: 43.13, Lon: 5.13}, - }, - []time.Time{time.Unix(0, 0), time.Unix(60, 0), time.Unix(120, 0), time.Unix(180, 0)}, - ) + parsed := ridetest.MustRide("2km at 5% | 1km at -10%", ridetest.StartCoord(43.10, 5.10), ridetest.StartElevation(100), ridetest.Sampling(1000)) official := official_climb.OfficialClimb{ Name: "Too far", StartCoord: geodist.Coord{Lat: 43.09, Lon: 5.09}, |
