-
Notifications
You must be signed in to change notification settings - Fork 2
/
nemtime_test.go
64 lines (56 loc) · 1.48 KB
/
nemtime_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
package nemtime
import (
"testing"
)
var (
incorrectInputFormat = "J03L5ux"
startDates = map[string]string{
"2018-01-01": "2018-01-01T00:00:00+10:00",
"2018-02-01": "2018-02-01T00:00:00+10:00",
"2018-03-01": "2018-03-01T00:00:00+10:00",
"2018-04-01": "2018-04-01T00:00:00+10:00",
"2018-05-01": "2018-05-01T00:00:00+10:00",
"2018-06-01": "2018-06-01T00:00:00+10:00",
}
endDates = map[string]string{
"2018-06-30": "2018-07-01T00:00:00+10:00",
"2018-07-31": "2018-08-01T00:00:00+10:00",
"2018-08-31": "2018-09-01T00:00:00+10:00",
"2018-09-30": "2018-10-01T00:00:00+10:00",
"2018-10-31": "2018-11-01T00:00:00+10:00",
"2018-11-30": "2018-12-01T00:00:00+10:00",
"2018-12-31": "2019-01-01T00:00:00+10:00",
}
)
func TestStartDateStringToNEMTimeString(t *testing.T) {
for k, v := range startDates {
out, err := FromStartDateString(k)
if err != nil {
t.Error(err)
}
if out.String() != v {
t.Errorf("Expected output to be %v, got %v", v, out)
}
}
}
func TestEndDateStringToNEMTimeString(t *testing.T) {
for k, v := range endDates {
out, err := FromEndDateString(k)
if err != nil {
t.Error(err)
}
if out.String() != v {
t.Errorf("Expected output to be %v, got %v", v, out)
}
}
}
func TestErrors(t *testing.T) {
_, err := FromStartDateString(incorrectInputFormat)
if err == nil {
t.Error("Expected an error, got none!")
}
_, err = FromEndDateString(incorrectInputFormat)
if err == nil {
t.Error("Expected an error, got none!")
}
}