test: expand route coverage
This commit is contained in:
parent
859a7ea3b8
commit
16c0093b92
@ -306,6 +306,40 @@ func TestRunRouteHuman(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunRouteValidationError(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
exitCode := Run([]string{
|
||||
"route",
|
||||
"coffee",
|
||||
"--from", "A",
|
||||
"--to", "B",
|
||||
"--mode", "FLY",
|
||||
"--api-key", "test-key",
|
||||
}, &stdout, &stderr)
|
||||
|
||||
if exitCode != 2 {
|
||||
t.Fatalf("expected validation error exit code 2, got %d", exitCode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunRouteMissingFrom(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
exitCode := Run([]string{
|
||||
"route",
|
||||
"coffee",
|
||||
"--to", "B",
|
||||
"--api-key", "test-key",
|
||||
}, &stdout, &stderr)
|
||||
|
||||
if exitCode != 2 {
|
||||
t.Fatalf("expected validation error exit code 2, got %d", exitCode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunDetailsJSON(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/places/place-1" {
|
||||
|
||||
@ -95,6 +95,25 @@ func TestSampleWaypointsSinglePoint(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSampleWaypointsZeroTotal(t *testing.T) {
|
||||
points := []LatLng{{Lat: 1, Lng: 1}, {Lat: 1, Lng: 1}}
|
||||
waypoints := sampleWaypoints(points, 3)
|
||||
if len(waypoints) != 1 {
|
||||
t.Fatalf("expected 1 waypoint")
|
||||
}
|
||||
if waypoints[0] != points[0] {
|
||||
t.Fatalf("unexpected waypoint: %#v", waypoints[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestSampleWaypointsMaxExceedsPoints(t *testing.T) {
|
||||
points := []LatLng{{Lat: 0, Lng: 0}, {Lat: 0, Lng: 0}, {Lat: 0, Lng: 1}}
|
||||
waypoints := sampleWaypoints(points, 5)
|
||||
if len(waypoints) != 2 {
|
||||
t.Fatalf("expected 2 waypoints, got %d", len(waypoints))
|
||||
}
|
||||
}
|
||||
|
||||
func TestPointAtDistanceBounds(t *testing.T) {
|
||||
points := []LatLng{{Lat: 0, Lng: 0}, {Lat: 0, Lng: 2}}
|
||||
cumulative := cumulativeDistances(points)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user