test: logs pkg

pull/14/head
sundowndev 2023-01-03 14:46:12 +04:00
parent 49cb7ca0d0
commit ad93c6b047
1 changed files with 25 additions and 0 deletions

25
logs/config_test.go Normal file
View File

@ -0,0 +1,25 @@
package logs
import (
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestConfig_GetConfig(t *testing.T) {
t.Run("test default behavior", func(t *testing.T) {
Init()
config := getConfig()
assert.Equal(t, logrus.DebugLevel, config.Level)
})
t.Run("test custom log level", func(t *testing.T) {
_ = os.Setenv("LOG_LEVEL", "warn")
defer os.Clearenv()
Init()
config := getConfig()
assert.Equal(t, logrus.WarnLevel, config.Level)
})
}