Skip to content

Commit

Permalink
Found work around for in memory issue
Browse files Browse the repository at this point in the history
  • Loading branch information
despicableGruu committed Mar 24, 2017
1 parent 393c93a commit 6662303
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions db/sqlite/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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) {
Expand Down

0 comments on commit 6662303

Please sign in to comment.