mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 23:42:29 -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:
parent
9cca8d1db6
commit
82362f7ebc
@ -12,7 +12,6 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -175,14 +174,7 @@ func RunWith(t *testing.T, d *TestData, fn TestDataFunc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunTests(m *testing.M) int {
|
func RunTests(m *testing.M) int {
|
||||||
tmpdir, err := ioutil.TempDir("./", "handlertest")
|
dsn := db.GetDSN(config.SQLite, ":memory:")
|
||||||
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")
|
|
||||||
database, err := sql.Open("sqlite3", dsn)
|
database, err := sql.Open("sqlite3", dsn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user