Update tests helper to check time

This commit is contained in:
Jinzhu 2020-07-09 09:42:27 +08:00
parent 2ae0653af2
commit 0790ff6937
1 changed files with 1 additions and 1 deletions

View File

@ -27,7 +27,7 @@ func AssertEqual(t *testing.T, got, expect interface{}) {
if curTime, ok := got.(time.Time); ok {
format := "2006-01-02T15:04:05Z07:00"
if curTime.Round(time.Second).Format(format) != expect.(time.Time).Round(time.Second).Format(format) && curTime.Truncate(time.Second).Format(format) != expect.(time.Time).Truncate(time.Second).Format(format) {
if curTime.Round(time.Second).UTC().Format(format) != expect.(time.Time).Round(time.Second).UTC().Format(format) && curTime.Truncate(time.Second).UTC().Format(format) != expect.(time.Time).Truncate(time.Second).UTC().Format(format) {
t.Errorf("%v: expect: %v, got %v after time round", utils.FileWithLineNum(), expect.(time.Time), curTime)
}
} else if fmt.Sprint(got) != fmt.Sprint(expect) {