Skip to content

Commit

Permalink
Fix tests & rows closing
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Nov 21, 2020
1 parent 3b73e8c commit 8e9d19c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions driver/gorm/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func TakeMap(tx *gorm.DB) (map[string]interface{}, error) {
if err != nil {
return nil, err
}
defer rows.Close()

if !rows.Next() {
return nil, nil
Expand All @@ -28,6 +29,7 @@ func FindMap(tx *gorm.DB) ([]map[string]interface{}, error) {
if err != nil {
return nil, err
}
defer rows.Close()

return rowsMap(rows)
}
Expand Down
6 changes: 6 additions & 0 deletions driver/gorm/paginator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ func SetupDb(models ...interface{}) (*gormdb.DB, context.CancelFunc) {
panic(fmt.Sprintf("Failed to connect to db: %v", err))
}

sqlDB, err := db.DB()
if err != nil {
panic(fmt.Sprintf("Failed to get db: %v", err))
}
sqlDB.SetMaxOpenConns(1)

db.AutoMigrate(models...)

ctx, cancel := context.WithCancel(context.Background())
Expand Down

0 comments on commit 8e9d19c

Please sign in to comment.