From bcff1df58916f4dbc364589e6468d54fe3041262 Mon Sep 17 00:00:00 2001 From: zardak Date: Sun, 7 Aug 2016 13:00:06 +0300 Subject: [PATCH] Fix failing sqlite3 tests due to db connection not being closed --- main_test.go | 17 +++++++++-------- query_test.go | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/main_test.go b/main_test.go index 315dd95e..b34c80d7 100644 --- a/main_test.go +++ b/main_test.go @@ -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() } @@ -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 } diff --git a/query_test.go b/query_test.go index 62f86ce9..1a500465 100644 --- a/query_test.go +++ b/query_test.go @@ -628,6 +628,8 @@ func TestSelectWithVariables(t *testing.T) { t.Errorf("Should only contains one column") } } + + rows.Close() } func TestSelectWithArrayInput(t *testing.T) {