mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-15 14:12:47 +00:00
fix(manager): timezone issue of status test
This commit is contained in:
parent
42c645a736
commit
d1981379a4
@ -13,11 +13,11 @@ type textTime struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t textTime) MarshalJSON() ([]byte, error) {
|
func (t textTime) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(t.Format("2006-01-02 15:04:05"))
|
return json.Marshal(t.Format("2006-01-02 15:04:05 -0700"))
|
||||||
}
|
}
|
||||||
func (t *textTime) UnmarshalJSON(b []byte) error {
|
func (t *textTime) UnmarshalJSON(b []byte) error {
|
||||||
s := string(b)
|
s := string(b)
|
||||||
t2, err := time.ParseInLocation(`"2006-01-02 15:04:05"`, s, time.Local)
|
t2, err := time.Parse(`"2006-01-02 15:04:05 -0700"`, s)
|
||||||
*t = textTime{t2}
|
*t = textTime{t2}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func TestStatus(t *testing.T) {
|
func TestStatus(t *testing.T) {
|
||||||
Convey("status json ser-de should work", t, func() {
|
Convey("status json ser-de should work", t, func() {
|
||||||
tz := "Asia/Shanghai"
|
tz := "Asia/Tokyo"
|
||||||
loc, err := time.LoadLocation(tz)
|
loc, err := time.LoadLocation(tz)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
t := time.Date(2016, time.April, 16, 23, 8, 10, 0, loc)
|
t := time.Date(2016, time.April, 16, 23, 8, 10, 0, loc)
|
||||||
@ -27,7 +27,7 @@ func TestStatus(t *testing.T) {
|
|||||||
|
|
||||||
b, err := json.Marshal(m)
|
b, err := json.Marshal(m)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
// fmt.Println(string(b))
|
//fmt.Println(string(b))
|
||||||
var m2 webMirrorStatus
|
var m2 webMirrorStatus
|
||||||
err = json.Unmarshal(b, &m2)
|
err = json.Unmarshal(b, &m2)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user