Merge pull request #70 from pingcap/qiuyesuifeng/fix-time-test-location-bug
mysqldef: fix TestCodec location bug.
This commit is contained in:
@ -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)
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user