From ae3ae4b6ef0962b02ffcc6c6f5a0a906e444d43e Mon Sep 17 00:00:00 2001 From: Andrew Miller Date: Fri, 24 Mar 2017 14:18:51 -0400 Subject: [PATCH] Found work around for in memory issue https://github.com/mattn/go-sqlite3/issues/204 --- db/sqlite/sqlite_test.go | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/db/sqlite/sqlite_test.go b/db/sqlite/sqlite_test.go index 55e4c94..649539a 100644 --- a/db/sqlite/sqlite_test.go +++ b/db/sqlite/sqlite_test.go @@ -37,22 +37,7 @@ var tableNames = []string{ var tempDir = path.Join(os.TempDir(), "qnote-db") func openDatabase(t *testing.T) *Database { - // Ensure there is no left overs - if err := os.MkdirAll(tempDir, 0700); err != nil { - t.Fatal(err) - } - - file := path.Join(tempDir, "qnote.db") - if _, err := os.Stat(file); err == nil { - if err := os.Remove(file); err != nil { - t.Fatal(err) - } - } - - // Would be nice to be able to use a memory only db. Due, to - // the way Go sql.DB does its connection pool we can not. - // https://groups.google.com/forum/#!msg/golang-nuts/AYZl1lNxCfA/LOr30uKy7-oJ - db, err := NewDatabase(file) + db, err := NewDatabase("file::memory:?cache=shared") if err != nil { t.Fatal(err) } @@ -64,9 +49,6 @@ func closeDatabase(db *Database, t *testing.T) { if err := db.Close(); err != nil { t.Error(err) } - if err := os.Remove(db.DBPath); err != nil { - t.Fatal(err) - } } func TestCreateDatabaseSQLite(t *testing.T) {