Skip to content

Commit

Permalink
mysqldef: fix TestCodec location bug.
Browse files Browse the repository at this point in the history
fix issue #68.
  • Loading branch information
qiuyesuifeng committed Sep 8, 2015
1 parent 6d79f7d commit a9c1983
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion mysqldef/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ func (s *testTimeSuite) TestYear(c *C) {

}

func (s *testTimeSuite) getLocation(c *C) *time.Location {
locations := []string{"Asia/Shanghai", "Europe/Berlin"}
timeFormat := "Jan 2, 2006 at 3:04pm (MST)"

z, err := time.LoadLocation(locations[0])
c.Assert(err, IsNil)

t1, err := time.ParseInLocation(timeFormat, "Jul 9, 2012 at 5:02am (CEST)", z)
c.Assert(err, IsNil)
t2, err := time.Parse(timeFormat, "Jul 9, 2012 at 5:02am (CEST)")
c.Assert(err, IsNil)

if t1.Equal(t2) {
z, err = time.LoadLocation(locations[1])
c.Assert(err, IsNil)
}

return z
}

func (s *testTimeSuite) TestCodec(c *C) {
t, err := ParseTimestamp("2010-10-10 10:11:11")
c.Assert(err, IsNil)
Expand All @@ -298,7 +318,7 @@ func (s *testTimeSuite) TestCodec(c *C) {
var t1 Time
t1.Type = TypeTimestamp

z, _ := time.LoadLocation("Europe/Berlin")
z := s.getLocation(c)

err = t1.UnmarshalInLocation(b, z)
c.Assert(err, IsNil)
Expand Down

0 comments on commit a9c1983

Please sign in to comment.