package mdb_test import ( _ "embed" "testing" "git.sunturtle.xyz/zephyr/horse" "git.sunturtle.xyz/zephyr/horse/mdb" "github.com/google/go-cmp/cmp" ) //go:embed testdata/racecourse.sql var racecourseSQL string func TestRacecourses(t *testing.T) { db := testdb(t.Context(), "file:TestRacecourses?mode=memory&cache=shared", racecourseSQL) got, err := mdb.Racecourses(t.Context(), db) if err != nil { t.Error(err) } want := []horse.Racecourse{ { ID: 10301, TrackID: 10003, TrackName: "Niigata", Distance: 1000, Ground: 1, InOut: 1, Turn: 4, LaneMax: 13500, Threshold1: 3, Threshold2: 0, LaneStart: [18]horse.TenThousandths{0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4444, 5333, 5888, 6444, 7000, 7555, 8111, 8666, 9222, 9777}, Spans: []horse.RacecourseSpan{ { Start: 0, End: 649.9000244140625, Straight: true, }, { Start: 649.9000244140625, End: 650, }, { Start: 650, End: 1000, Straight: true, }, }, Slopes: []horse.Slope{}, MoveLanePoint: 30, }, { ID: 10811, TrackID: 10008, TrackName: "Kyoto", Distance: 3200, Ground: 1, InOut: 3, Turn: 1, LaneMax: 14100, Threshold1: 0, Threshold2: 0, LaneStart: [18]horse.TenThousandths{0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4444, 5333, 5888, 6444, 7000, 7555, 8111, 8666, 9222, 9777}, Spans: []horse.RacecourseSpan{ { Start: 0, End: 458, Straight: true, FarStraight: true, }, { Start: 458, End: 708, Corner: 3, }, { Start: 708, End: 958, Corner: 4, }, { Start: 958, End: 1450, Straight: true, }, { Start: 1450, End: 1650, Corner: 1, }, { Start: 1650, End: 1850, Corner: 2, }, { Start: 1850, End: 2300, Straight: true, FarStraight: true, }, { Start: 2300, End: 2550, Corner: 3, }, { Start: 2550, End: 2797, Corner: 4, }, { Start: 2797, End: 3200, Straight: true, }, }, Slopes: []horse.Slope{ { Per: 20000, Start: 208, End: 308, }, { Per: 10000, Start: 308, End: 533, }, { Per: -20000, Start: 533, End: 683, }, { Per: 20000, Start: 2050, End: 2150, }, { Per: 10000, Start: 2150, End: 2375, }, { Per: -20000, Start: 2375, End: 2525, }, }, MoveLanePoint: 458, }, { ID: 11103, TrackID: 10101, TrackName: "Oi", Distance: 2000, Ground: 2, InOut: 1, Turn: 1, LaneMax: 12000, Threshold1: 2, Threshold2: 0, LaneStart: [18]horse.TenThousandths{0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4444, 5000, 5555, 6111, 6666, 7222, 7777, 8333, 8888, 9444}, Spans: []horse.RacecourseSpan{ { Start: 0, End: 500, Straight: true, }, { Start: 500, End: 650, Corner: 1, }, { Start: 650, End: 800, Corner: 2, }, { Start: 800, End: 1300, Straight: true, FarStraight: true, }, { Start: 1300, End: 1450, Corner: 3, }, { Start: 1450, End: 1614, Corner: 4, }, { Start: 1614, End: 2000, Straight: true, }, }, Slopes: []horse.Slope{}, MoveLanePoint: 500, }, { ID: 11203, TrackID: 10201, TrackName: "Longchamp", Distance: 2400, Ground: 1, InOut: 1, Turn: 1, LaneMax: 12000, Threshold1: 3, Threshold2: 0, LaneStart: [18]horse.TenThousandths{0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4444, 5000, 5555, 6111, 6666, 7222, 8811, 9366, 9922, 10477}, Spans: []horse.RacecourseSpan{ { Start: 0, End: 798, Straight: true, FarStraight: true, }, { Start: 798, End: 800, }, { Start: 800, End: 1200, Corner: 3, }, { Start: 1200, End: 1600, Corner: 4, }, { Start: 1600, End: 2400, Straight: true, }, }, Slopes: []horse.Slope{}, MoveLanePoint: 800, }, { ID: 11504, TrackID: 10105, TrackName: "Morioka", Distance: 2000, Ground: 2, InOut: 1, Turn: 2, LaneMax: 13500, Threshold1: 2, Threshold2: 0, LaneStart: [18]horse.TenThousandths{0, 555, 1111, 1666, 2222, 2777, 3333, 3888, 4777, 5333, 5888, 6444, 7000, 7555, 8111, 8666, 9222, 9777}, Spans: []horse.RacecourseSpan{ { Start: 0, End: 100, }, { Start: 100, End: 500, Straight: true, }, { Start: 500, End: 700, Corner: 1, }, { Start: 700, End: 900, Corner: 2, }, { Start: 900, End: 1300, Straight: true, FarStraight: true, }, { Start: 1300, End: 1500, Corner: 3, }, { Start: 1500, End: 1700, Corner: 4, }, { Start: 1700, End: 2000, Straight: true, }, }, Slopes: []horse.Slope{ { Per: 10000, Start: 175, End: 350, }, { Per: 10000, Start: 900, End: 1275, }, { Per: -15000, Start: 1275, End: 1725, }, { Per: 10000, Start: 1775, End: 1950, }, }, MoveLanePoint: 500, }, } if diff := cmp.Diff(want, got); diff != "" { t.Errorf("wrong racecourses (+got/-want):\n%s", diff) } }