58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"git.tornberg.me/go-gtfs/pkg/reader"
|
|
)
|
|
|
|
var tripData *reader.TripData
|
|
|
|
func init() {
|
|
var err error
|
|
tripData, err = reader.LoadTripData("../../data")
|
|
if err != nil {
|
|
panic("Failed to load trip data: " + err.Error())
|
|
}
|
|
}
|
|
|
|
func TestFindRouteToStockholm(t *testing.T) {
|
|
|
|
tp := NewTripPlanner(tripData)
|
|
|
|
//tp.Preprocess()
|
|
|
|
route, err := tp.FindRoute("740000030", "740000001", time.Now().Add(time.Hour*-16))
|
|
if err != nil {
|
|
t.Fatalf("Error finding route: %v", err)
|
|
}
|
|
if route == nil {
|
|
t.Fatal("No route found from Falun Centralstation to Stockholm Centralstation")
|
|
}
|
|
|
|
if len(route.Legs) < 1 {
|
|
t.Fatal("Route has no legs")
|
|
}
|
|
|
|
}
|
|
|
|
func TestFindRouteToMalmo(t *testing.T) {
|
|
tp := NewTripPlanner(tripData)
|
|
|
|
//tp.Preprocess()
|
|
|
|
route, err := tp.FindRoute("740000030", "740000003", time.Now().Add(time.Hour*-16))
|
|
if err != nil {
|
|
t.Fatalf("Error finding route: %v", err)
|
|
}
|
|
if route == nil {
|
|
t.Fatal("No route found from Falun Centralstation to Malmö Centralstation")
|
|
}
|
|
|
|
if len(route.Legs) < 1 {
|
|
t.Fatal("Route has no legs")
|
|
}
|
|
|
|
}
|