move from test init()s to TestMain
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -25,16 +26,6 @@ var (
|
||||
testController *Controller
|
||||
)
|
||||
|
||||
func init() {
|
||||
db, err := db.New(testDBPath)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening database: %v\n", err)
|
||||
}
|
||||
testController = &Controller{
|
||||
Controller: &ctrlbase.Controller{DB: db},
|
||||
}
|
||||
}
|
||||
|
||||
type queryCase struct {
|
||||
params url.Values
|
||||
expectPath string
|
||||
@@ -86,3 +77,14 @@ func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
db, err := db.New(testDBPath)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening database: %v\n", err)
|
||||
}
|
||||
testController = &Controller{
|
||||
Controller: &ctrlbase.Controller{DB: db},
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user