-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstatus_test.go
83 lines (64 loc) · 1.73 KB
/
status_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
81
82
83
package rail_test
import (
"context"
"testing"
"time"
"github.com/go-india/rail"
)
func TestLiveTrainStatus(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
resp, err := c.LiveTrainStatus(context.Background(), 12138, time.Now())
if err != nil {
t.Fatal("LiveTrainStatus failed:", err)
}
if len(resp.Route) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestTrainRoute(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
resp, err := c.TrainRoute(context.Background(), 14311)
if err != nil {
t.Fatal("TrainRoute failed:", err)
}
if len(resp.Route) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestCheckSeat(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.CheckSeat(context.Background(), 14311, "BE", "ADI", "SL", "GN", d)
if err != nil {
t.Fatal("CheckSeat failed:", err)
}
if len(resp.Availability) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestPNRStatus(t *testing.T) {
c := rail.NewClient(getAPIKey())
testClient(&c, t)
resp, err := c.PNRStatus(context.Background(), 2144287856)
if err != nil {
t.Fatal("PNRStatus failed:", err)
}
if len(resp.Passengers) < 1 || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}
func TestTrainFare(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.TrainFare(context.Background(), 14311, "BE", "ADI", 24, "SL", "GN", d)
if err != nil {
t.Fatal("TrainFare failed:", err)
}
if resp.Train == nil || resp.ResponseCode != 200 {
t.Fatal("invalid response")
}
}