1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-12-26 07:33:21 -05:00

testing: Use an in-memory sqlite3 database

This makes testing *much* faster and removes the need for creating
temporary directories
This commit is contained in:
Aaron Lindsay 2017-11-01 21:09:55 -04:00
parent 9cca8d1db6
commit 82362f7ebc

View File

@ -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)