3b797d7957
Dedicated type `LoggerSection` turned out to be redundant since it doesn't do a hidden logic and just uses `config.Config` API. Remove `LoggerSection` type and implement `Level` which do the same. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
34 lines
916 B
Go
34 lines
916 B
Go
package loggerconfig_test
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/internal"
|
|
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) {
|
|
v := loggerconfig.Level(c)
|
|
require.Equal(t, "debug", v)
|
|
})
|
|
|
|
v := loggerconfig.Level(configtest.EmptyConfig())
|
|
require.Equal(t, loggerconfig.LevelDefault, v)
|
|
|
|
t.Run("ENV", func(t *testing.T) {
|
|
// TODO: read from file
|
|
err := os.Setenv(
|
|
internal.Env("logger", "level"),
|
|
"debug",
|
|
)
|
|
require.NoError(t, err)
|
|
|
|
v := loggerconfig.Level(configtest.EmptyConfig())
|
|
require.Equal(t, "debug", v)
|
|
})
|
|
}
|