Skip to content

Commit

Permalink
fix possible nil panic in tests (#5720)
Browse files Browse the repository at this point in the history
* fix maybe nil panic

* reset code
  • Loading branch information
demoManito committed Sep 30, 2022
1 parent e1dd0dc commit be440e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/callbacks_test.go
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/transaction_test.go
Expand Up @@ -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")
}

Expand Down

0 comments on commit be440e7

Please sign in to comment.