-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstation_test.go
80 lines (63 loc) · 1.72 KB
/
station_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package rail_test
import (
"context"
"testing"
"time"
"github.com/go-india/rail"
)
func TestTrainBetweenStations(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
d := time.Date(2018, time.April, 5, 0, 0, 0, 0, time.UTC)
resp, err := c.TrainBetweenStations(context.Background(), "BE", "ADI", d)
if err != nil {
t.Fatal("TrainBetweenStations failed:", err)
}
if len(resp.Trains) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestTrainArrivals(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
resp, err := c.TrainArrivals(context.Background(), "BE", rail.WindowHour2)
if err != nil {
t.Fatal("TrainArrivals failed:", err)
}
if len(resp.Trains) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestStationNameToCode(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
resp, err := c.StationNameToCode(context.Background(), "bareilly")
if err != nil {
t.Fatal("StationNameToCode failed:", err)
}
if len(resp.Stations) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestStationCodeToName(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
resp, err := c.StationCodeToName(context.Background(), "BE")
if err != nil {
t.Fatal("StationCodeToName failed:", err)
}
if len(resp.Stations) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestSuggestStation(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
resp, err := c.SuggestStation(context.Background(), "bareilly")
if err != nil {
t.Fatal("SuggestStation failed:", err)
}
if len(resp.Stations) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}