gorm/tests/utils.go

20 lines
445 B
Go
Raw Normal View History

2020-02-02 09:40:44 +03:00
package tests
import (
"reflect"
"testing"
)
func AssertEqual(t *testing.T, r, e interface{}, names ...string) {
for _, name := range names {
got := reflect.Indirect(reflect.ValueOf(r)).FieldByName(name).Interface()
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)
})
}
}
}