代码拉取完成,页面将自动刷新
package tegenaria
import (
"errors"
"testing"
"github.com/agiledragon/gomonkey/v2"
"github.com/sirupsen/logrus"
"github.com/smartystreets/goconvey/convey"
"github.com/spf13/viper"
)
func TestLogger(t *testing.T) {
convey.Convey("test logger", t, func() {
log := GetLogger("test")
log.Infof("testtest")
})
convey.Convey("test log level empty", t, func() {
patch := gomonkey.ApplyFunc((*viper.Viper).GetString, func(_ *viper.Viper, _ string) string {
return ""
})
defer patch.Reset()
initLog()
convey.So(logger.Level.String(), convey.ShouldContainSubstring, "info")
})
convey.Convey("test log level parser error", t, func() {
patch := gomonkey.ApplyFunc(logrus.ParseLevel, func(_ string) (logrus.Level, error) {
return logrus.ErrorLevel, errors.New("parse level error")
})
defer patch.Reset()
f := func() {
initLog()
}
convey.So(f, convey.ShouldPanic)
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。