fix zap.Logger in webtest
continuous-integration/drone the build failed
Details
continuous-integration/drone the build failed
Details
This commit is contained in:
parent
36c185100b
commit
694ca30e0d
|
@ -45,6 +45,11 @@ type Service struct {
|
|||
modules []ModuleRegisterFunc
|
||||
}
|
||||
|
||||
// SetLog - set new logger
|
||||
func (s *Service) SetLog(l *zap.Logger) {
|
||||
s.log = l
|
||||
}
|
||||
|
||||
// Log - get current logger
|
||||
func (s *Service) Log() *zap.Logger {
|
||||
return s.log
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,13 +18,13 @@ func TestRun(t *testing.T) {
|
|||
s := &Service{AccessLog: true, Listen: "8.8.8.8:80"}
|
||||
s.ModuleRegister(func(_ *gin.Engine, _ *Service) {})
|
||||
// HTTP - failed
|
||||
err := s.Run()
|
||||
err := s.Run(zap.L())
|
||||
assert.Error(err)
|
||||
|
||||
s.ACME.Enable = true
|
||||
// acme with listen port - panic
|
||||
assert.Panics(func() {
|
||||
s.Run()
|
||||
s.Run(zap.L())
|
||||
})
|
||||
|
||||
if TestRunTLS == "false" {
|
||||
|
@ -31,6 +32,6 @@ func TestRun(t *testing.T) {
|
|||
}
|
||||
s.Listen = ""
|
||||
// httpS - failed
|
||||
err = s.Run()
|
||||
err = s.Run(zap.L())
|
||||
assert.Error(err)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"dev.sum7.eu/genofire/golang-lib/database"
|
||||
"dev.sum7.eu/genofire/golang-lib/mailer"
|
||||
|
@ -63,8 +64,10 @@ func NewWithDBSetup(modules web.ModuleRegisterFunc, dbCall func(db *database.Dat
|
|||
|
||||
// New allows to configure WebService for testing
|
||||
func (option Option) New() (*TestServer, error) {
|
||||
log := zap.L()
|
||||
|
||||
ws := &web.Service{}
|
||||
ws.SetLog(log)
|
||||
ws.Session.Name = "mysession"
|
||||
ws.Session.Secret = "hidden"
|
||||
|
||||
|
@ -100,7 +103,7 @@ func (option Option) New() (*TestServer, error) {
|
|||
}
|
||||
|
||||
if option.Mailer {
|
||||
mock, mail := mailer.NewFakeServer()
|
||||
mock, mail := mailer.NewFakeServer(log)
|
||||
if err := mail.Setup(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue