Fix test failed due to time round

This commit is contained in:
Jinzhu 2020-05-30 14:29:05 +08:00
parent 05e1af3bfb
commit d2741ae51e
1 changed files with 2 additions and 2 deletions

View File

@ -86,8 +86,8 @@ func AssertEqual(t *testing.T, got, expect interface{}) {
if curTime, ok := got.(time.Time); ok {
format := "2006-01-02T15:04:05Z07:00"
if curTime.Format(format) != expect.(time.Time).Format(format) {
t.Errorf("%v: expect: %v, got %v", utils.FileWithLineNum(), expect.(time.Time).Format(format), curTime.Format(format))
if curTime.Round(time.Second).Format(format) != expect.(time.Time).Round(time.Second).Format(format) {
t.Errorf("%v: expect: %v, got %v", utils.FileWithLineNum(), expect.(time.Time).Round(time.Second).Format(format), curTime.Round(time.Second).Format(format))
}
} else if got != expect {
t.Errorf("%v: expect: %#v, got %#v", utils.FileWithLineNum(), expect, got)