-
Notifications
You must be signed in to change notification settings - Fork 2
/
factories_test.go
88 lines (79 loc) · 1.89 KB
/
factories_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
84
85
86
87
88
package bete
import (
"encoding/base64"
"math/rand"
"time"
"github.com/yi-jiayu/datamall/v3"
)
var refTime = time.Unix(1584244383, 0)
var factoryRand = rand.New(rand.NewSource(time.Now().UnixNano()))
func randomID() int {
return factoryRand.Int()
}
func randomInt64ID() int64 {
return factoryRand.Int63()
}
func randomStringID() string {
p := make([]byte, 6)
_, err := factoryRand.Read(p)
if err != nil {
return "abcdef"
}
return base64.StdEncoding.EncodeToString(p)
}
func buildDataMallBusArrival() datamall.BusArrival {
return datamall.BusArrival{
BusStopCode: "96049",
Services: []datamall.Service{
{
ServiceNo: "5",
NextBus: datamall.ArrivingBus{
EstimatedArrival: refTime.Add(-100 * time.Second),
Load: "SDA",
Type: "DD",
},
NextBus2: datamall.ArrivingBus{
EstimatedArrival: refTime.Add(600 * time.Second),
Load: "SDA",
Type: "DD",
},
NextBus3: datamall.ArrivingBus{
EstimatedArrival: refTime.Add(2200 * time.Second),
Load: "LSD",
Feature: "WAB",
Type: "BD",
},
},
{
ServiceNo: "24",
NextBus: datamall.ArrivingBus{
EstimatedArrival: refTime.Add(100 * time.Second),
Load: "SEA",
Type: "SD",
},
NextBus2: datamall.ArrivingBus{
EstimatedArrival: refTime.Add(200 * time.Second),
Load: "SDA",
Type: "DD",
Feature: "WAB",
},
NextBus3: datamall.ArrivingBus{
EstimatedArrival: refTime.Add(400 * time.Second),
Load: "LSD",
Type: "BD",
},
},
},
}
}
func buildBusStop() BusStop {
return BusStop{
ID: "96049",
Description: "UPP CHANGI STN/SUTD",
RoadName: "Upp Changi Rd East",
Location: Location{
Latitude: 1.340874,
Longitude: 103.961433,
},
}
}