Skip to content

Commit

Permalink
Fix failing sqlite3 tests due to db connection not being closed
Browse files Browse the repository at this point in the history
  • Loading branch information
zardak committed Aug 7, 2016
1 parent a646b13 commit bcff1df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 9 additions & 8 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ func init() {
panic(fmt.Sprintf("No error should happen when connecting to test database, but got err=%+v", err))
}

// DB.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)})
// DB.SetLogger(log.New(os.Stdout, "\r\n", 0))
if os.Getenv("DEBUG") == "true" {
DB.LogMode(true)
}

DB.DB().SetMaxIdleConns(10)

runMigration()
}

Expand Down Expand Up @@ -72,6 +64,15 @@ func OpenTestConnection() (db *gorm.DB, err error) {
fmt.Println("testing sqlite3...")
db, err = gorm.Open("sqlite3", filepath.Join(os.TempDir(), "gorm.db"))
}

// db.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)})
// db.SetLogger(log.New(os.Stdout, "\r\n", 0))
if os.Getenv("DEBUG") == "true" {
db.LogMode(true)
}

db.DB().SetMaxIdleConns(10)

return
}

Expand Down
2 changes: 2 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ func TestSelectWithVariables(t *testing.T) {
t.Errorf("Should only contains one column")
}
}

rows.Close()
}

func TestSelectWithArrayInput(t *testing.T) {
Expand Down

0 comments on commit bcff1df

Please sign in to comment.