@@ -16,11 +16,12 @@ func TestTimeUnmarshalJSON(t *testing.T) {
1616
1717 testCases := []testCase {
1818 {
19- err : true ,
19+ in : []byte ("null" ),
20+ exp : luno.Time {},
2021 },
2122 {
2223 in : []byte {},
23- err : true ,
24+ exp : luno. Time {} ,
2425 },
2526 {
2627 in : []byte ("abc" ),
@@ -34,6 +35,14 @@ func TestTimeUnmarshalJSON(t *testing.T) {
3435 in : []byte ("-123456" ),
3536 exp : luno .Time (time .Unix (0 , - 123456e6 )),
3637 },
38+ {
39+ in : []byte (`"2006-01-02T15:04:05Z"` ),
40+ exp : luno .Time (time .Date (2006 , 1 , 2 , 15 , 4 , 5 , 0 , time .UTC )),
41+ },
42+ {
43+ in : []byte (`"2006-01-02 15:04:05 +0000 UTC"` ),
44+ exp : luno .Time (time .Date (2006 , 1 , 2 , 15 , 4 , 5 , 0 , time .UTC )),
45+ },
3746 }
3847
3948 var act luno.Time
@@ -58,20 +67,16 @@ func TestTimeMarshalJSON(t *testing.T) {
5867 exp string
5968 }
6069
61- now := time .Now ( )
70+ date := time .Date ( 2006 , 1 , 2 , 3 , 4 , 5 , 0 , time . UTC )
6271
6372 testCases := []testCase {
6473 {
6574 in : luno.Time {},
66- exp : time.Time {}.String (),
67- },
68- {
69- in : luno .Time (now ),
70- exp : now .String (),
75+ exp : "null" ,
7176 },
7277 {
73- in : luno .Time (time . Date ( 2006 , 1 , 2 , 3 , 4 , 5 , 999 , time . UTC ) ),
74- exp : time . Date ( 2006 , 1 , 2 , 3 , 4 , 5 , 999 , time . UTC ). String () ,
78+ in : luno .Time (date ),
79+ exp : `" 2006-01-02T03:04:05Z"` ,
7580 },
7681 }
7782
0 commit comments