mirror of https://github.com/go-gorm/gorm.git
Update test helper
This commit is contained in:
parent
9fcc546a69
commit
0da8191f60
|
@ -3,6 +3,7 @@ package tests
|
|||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func AssertEqual(t *testing.T, r, e interface{}, names ...string) {
|
||||
|
@ -11,9 +12,18 @@ func AssertEqual(t *testing.T, r, e interface{}, names ...string) {
|
|||
expects := reflect.Indirect(reflect.ValueOf(e)).FieldByName(name).Interface()
|
||||
|
||||
if !reflect.DeepEqual(got, expects) {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Errorf("expects: %v, got %v", expects, got)
|
||||
})
|
||||
got = reflect.Indirect(reflect.ValueOf(got)).Interface()
|
||||
expects = reflect.Indirect(reflect.ValueOf(got)).Interface()
|
||||
if curTime, ok := got.(time.Time); ok {
|
||||
format := "2006-01-02T15:04:05Z07:00"
|
||||
if curTime.Format(format) != expects.(time.Time).Format(format) {
|
||||
t.Errorf("expects: %v, got %v", expects.(time.Time).Format(format), curTime.Format(format))
|
||||
}
|
||||
} else {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Errorf("expects: %v, got %v", expects, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue