forked from mirror/gorm
fix possible nil panic in tests (#5720)
* fix maybe nil panic * reset code
This commit is contained in:
parent
e1dd0dcbc4
commit
be440e7512
|
@ -113,6 +113,9 @@ func TestCallbacks(t *testing.T) {
|
||||||
|
|
||||||
for idx, data := range datas {
|
for idx, data := range datas {
|
||||||
db, err := gorm.Open(nil, nil)
|
db, err := gorm.Open(nil, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
callbacks := db.Callback()
|
callbacks := db.Callback()
|
||||||
|
|
||||||
for _, c := range data.callbacks {
|
for _, c := range data.callbacks {
|
||||||
|
|
|
@ -102,7 +102,7 @@ func TestTransactionWithBlock(t *testing.T) {
|
||||||
return errors.New("the error message")
|
return errors.New("the error message")
|
||||||
})
|
})
|
||||||
|
|
||||||
if err.Error() != "the error message" {
|
if err != nil && err.Error() != "the error message" {
|
||||||
t.Fatalf("Transaction return error will equal the block returns error")
|
t.Fatalf("Transaction return error will equal the block returns error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue