web/webtest: fix close testserver without mailer
continuous-integration/drone the build was successful Details

This commit is contained in:
genofire 2021-09-28 04:53:44 +02:00
parent b3f53011f2
commit 3fd1eac4d8
1 changed files with 9 additions and 5 deletions

View File

@ -64,16 +64,15 @@ func NewWithDBSetup(modules web.ModuleRegisterFunc, dbCall func(db *database.Dat
// New allows to configure WebService for testing // New allows to configure WebService for testing
func (option Option) New() (*TestServer, error) { func (option Option) New() (*TestServer, error) {
// api setup
gin.EnableJsonDecoderDisallowUnknownFields()
gin.SetMode(gin.TestMode)
ws := &web.Service{} ws := &web.Service{}
ws.Session.Name = "mysession" ws.Session.Name = "mysession"
ws.Session.Secret = "hidden" ws.Session.Secret = "hidden"
ts := &TestServer{ ts := &TestServer{
WS: ws, WS: ws,
Close: func() {},
} }
// db setup // db setup
if option.Database { if option.Database {
ts.DB = &database.Database{ ts.DB = &database.Database{
@ -110,6 +109,11 @@ func (option Option) New() (*TestServer, error) {
ts.Close = mock.Close ts.Close = mock.Close
} }
// api setup
gin.EnableJsonDecoderDisallowUnknownFields()
gin.SetMode(gin.TestMode)
ws.ModuleRegister(option.ModuleLoader) ws.ModuleRegister(option.ModuleLoader)
r := gin.Default() r := gin.Default()