mirror of
				https://github.com/aclindsa/moneygo.git
				synced 2025-11-03 18:13:27 -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:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user