fix(lint): warning from golangci-lint tool

https://github.com/appleboy/gorush/issues/704

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu
2022-12-20 22:03:29 +08:00
parent 89bc97d15e
commit 4ef30a0cdc
16 changed files with 145 additions and 122 deletions

View File

@@ -33,6 +33,7 @@ type LogPushEntry struct {
var isTerm bool
//nolint
func init() {
isTerm = isatty.IsTerminal(os.Stdout.Fd())
}

View File

@@ -11,13 +11,15 @@ import (
"github.com/stretchr/testify/assert"
)
var invalidLevel = "invalid"
func TestSetLogLevel(t *testing.T) {
log := logrus.New()
err := SetLogLevel(log, "debug")
assert.Nil(t, err)
err = SetLogLevel(log, "invalid")
err = SetLogLevel(log, invalidLevel)
assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
}
@@ -49,7 +51,7 @@ func TestInitDefaultLog(t *testing.T) {
cfg.Log.ErrorLog,
))
cfg.Log.AccessLevel = "invalid"
cfg.Log.AccessLevel = invalidLevel
assert.NotNil(t, InitLog(
cfg.Log.AccessLevel,
@@ -71,7 +73,7 @@ func TestInitDefaultLog(t *testing.T) {
func TestAccessLevel(t *testing.T) {
cfg, _ := config.LoadConf()
cfg.Log.AccessLevel = "invalid"
cfg.Log.AccessLevel = invalidLevel
assert.NotNil(t, InitLog(
cfg.Log.AccessLevel,
@@ -84,7 +86,7 @@ func TestAccessLevel(t *testing.T) {
func TestErrorLevel(t *testing.T) {
cfg, _ := config.LoadConf()
cfg.Log.ErrorLevel = "invalid"
cfg.Log.ErrorLevel = invalidLevel
assert.NotNil(t, InitLog(
cfg.Log.AccessLevel,