0678d19097
- The db test will run an sqlite3 database in in-memory mode and run the automigrations. - The template test will check if all the templates that are stored in package variables (template.Must) compile and if ReloadTemplates works without panicking.
24 lignes
401 o
Go
24 lignes
401 o
Go
package db
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ewhal/nyaa/config"
|
|
)
|
|
|
|
func TestGormInit(t *testing.T) {
|
|
conf := config.New()
|
|
conf.DBType = "sqlite3"
|
|
conf.DBParams = ":memory:?cache=shared&mode=memory"
|
|
|
|
db, err := GormInit(conf)
|
|
if err != nil {
|
|
t.Errorf("failed to initialize database: %v", err)
|
|
return
|
|
}
|
|
|
|
err = db.Close()
|
|
if err != nil {
|
|
t.Errorf("failed to close database: %v", err)
|
|
}
|
|
}
|