1 Star 0 Fork 1

wetrycode/tegenaria

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
logger_test.go 906 Bytes
一键复制 编辑 原始数据 按行查看 历史
geebytes 提交于 2023-01-21 20:08 +08:00 . chore:format codes
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)
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/wetrycode/tegenaria.git
git@gitee.com:wetrycode/tegenaria.git
wetrycode
tegenaria
tegenaria
master

搜索帮助