From 82362f7ebc6629bf514fa5064746aca5aa51623f Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Wed, 1 Nov 2017 21:09:55 -0400 Subject: [PATCH] testing: Use an in-memory sqlite3 database This makes testing *much* faster and removes the need for creating temporary directories --- internal/handlers/common_test.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/internal/handlers/common_test.go b/internal/handlers/common_test.go index c3eb51a..fadaf1e 100644 --- a/internal/handlers/common_test.go +++ b/internal/handlers/common_test.go @@ -12,7 +12,6 @@ import ( "net/http/httptest" "net/url" "os" - "path" "strings" "testing" ) @@ -175,14 +174,7 @@ func RunWith(t *testing.T, d *TestData, fn TestDataFunc) { } func RunTests(m *testing.M) int { - tmpdir, err := ioutil.TempDir("./", "handlertest") - if err != nil { - log.Fatal(err) - } - defer os.RemoveAll(tmpdir) - - dbpath := path.Join(tmpdir, "moneygo.sqlite") - dsn := db.GetDSN(config.SQLite, "file:"+dbpath+"?cache=shared&mode=rwc") + dsn := db.GetDSN(config.SQLite, ":memory:") database, err := sql.Open("sqlite3", dsn) if err != nil { log.Fatal(err)