2021-05-21 13:47:45 +00:00
|
|
|
package loggerconfig_test
|
|
|
|
|
|
|
|
import (
|
2021-05-21 17:51:59 +00:00
|
|
|
"os"
|
2021-05-21 13:47:45 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
2021-05-21 17:51:59 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/internal"
|
2021-05-21 13:47:45 +00:00
|
|
|
loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger"
|
|
|
|
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLoggerSection_Level(t *testing.T) {
|
|
|
|
configtest.ForEachFileType("../../../../config/example/node", func(c *config.Config) {
|
2021-05-21 18:03:47 +00:00
|
|
|
v := loggerconfig.Level(c)
|
|
|
|
require.Equal(t, "debug", v)
|
2021-05-21 13:47:45 +00:00
|
|
|
})
|
|
|
|
|
2021-05-21 18:03:47 +00:00
|
|
|
v := loggerconfig.Level(configtest.EmptyConfig())
|
|
|
|
require.Equal(t, loggerconfig.LevelDefault, v)
|
2021-05-21 17:51:59 +00:00
|
|
|
|
|
|
|
t.Run("ENV", func(t *testing.T) {
|
|
|
|
// TODO: read from file
|
|
|
|
err := os.Setenv(
|
|
|
|
internal.Env("logger", "level"),
|
|
|
|
"debug",
|
|
|
|
)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-05-21 18:03:47 +00:00
|
|
|
v := loggerconfig.Level(configtest.EmptyConfig())
|
|
|
|
require.Equal(t, "debug", v)
|
2021-05-21 17:51:59 +00:00
|
|
|
})
|
2021-05-21 13:47:45 +00:00
|
|
|
}
|