diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-14 21:28:20 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-14 21:28:20 +0200 |
| commit | bf5d6aaec3da5cf06cdb33792a34ff155f01ef78 (patch) | |
| tree | 6e921ab14f1231455b32c7de7fd5f118a1077524 /rides | |
| parent | 9b62eec13fb391a3055253422cc58252db820d99 (diff) | |
refactor: centralize test database setup
Diffstat (limited to 'rides')
| -rw-r--r-- | rides/rides_test.go | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/rides/rides_test.go b/rides/rides_test.go index eb705fa..90998cd 100644 --- a/rides/rides_test.go +++ b/rides/rides_test.go @@ -7,39 +7,15 @@ import ( "testing" "time" + "github.com/martinlehoux/biking_home/internal/dbtest" "github.com/martinlehoux/biking_home/ride" "github.com/martinlehoux/kagamigo/kcore" - _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func newTestDB(t *testing.T) *sql.DB { - t.Helper() - db, err := sql.Open("sqlite3", ":memory:") - require.NoError(t, err) - t.Cleanup(func() { db.Close() }) - _, err = db.Exec(` - create table rides ( - id integer primary key, - external_id text unique not null, - gpx_path text not null, - name text not null, - type text not null, - start_date text not null, - distance_m real not null, - moving_time_s integer not null, - elapsed_time_s integer not null, - total_elevation_gain_m real not null, - average_speed_mps real not null, - cotacol_score real, - cotacol_algo_version text, - created_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), - updated_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')) - ) - `) - require.NoError(t, err) - return db + return dbtest.New(t) } func sampleRide(t *testing.T) Ride { |