Skip to content

Commit ae3ae4b

Browse files
author
Andrew Miller
committed
Found work around for in memory issue
mattn/go-sqlite3#204
1 parent bbf9c80 commit ae3ae4b

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

db/sqlite/sqlite_test.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,7 @@ var tableNames = []string{
3737
var tempDir = path.Join(os.TempDir(), "qnote-db")
3838

3939
func openDatabase(t *testing.T) *Database {
40-
// Ensure there is no left overs
41-
if err := os.MkdirAll(tempDir, 0700); err != nil {
42-
t.Fatal(err)
43-
}
44-
45-
file := path.Join(tempDir, "qnote.db")
46-
if _, err := os.Stat(file); err == nil {
47-
if err := os.Remove(file); err != nil {
48-
t.Fatal(err)
49-
}
50-
}
51-
52-
// Would be nice to be able to use a memory only db. Due, to
53-
// the way Go sql.DB does its connection pool we can not.
54-
// https://groups.google.com/forum/#!msg/golang-nuts/AYZl1lNxCfA/LOr30uKy7-oJ
55-
db, err := NewDatabase(file)
40+
db, err := NewDatabase("file::memory:?cache=shared")
5641
if err != nil {
5742
t.Fatal(err)
5843
}
@@ -64,9 +49,6 @@ func closeDatabase(db *Database, t *testing.T) {
6449
if err := db.Close(); err != nil {
6550
t.Error(err)
6651
}
67-
if err := os.Remove(db.DBPath); err != nil {
68-
t.Fatal(err)
69-
}
7052
}
7153

7254
func TestCreateDatabaseSQLite(t *testing.T) {

0 commit comments

Comments
 (0)