fix possible nil panic in tests (#5720)

* fix maybe nil panic

* reset code
This commit is contained in:
jesse.tang 2022-09-30 11:14:34 +08:00 committed by GitHub
parent e1dd0dcbc4
commit be440e7512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -113,6 +113,9 @@ func TestCallbacks(t *testing.T) {
for idx, data := range datas {
db, err := gorm.Open(nil, nil)
if err != nil {
t.Fatal(err)
}
callbacks := db.Callback()
for _, c := range data.callbacks {

View File

@ -102,7 +102,7 @@ func TestTransactionWithBlock(t *testing.T) {
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")
}