frostfs-node/cmd/neofs-node/config/calls_test.go
Leonard Lyubich 1aa88159ca [#493] node/config: Change Sub implementation
In some cases viper doesn't interpret `section.value` as a subsection with
`section` name, but value is value still can be accessed through full
pathname.

Fix `Config.Sub` method implementation in order to always interpret
configuration like described above as a subsection. From now method never
returns nil, therefore an additional check has been removed from the `Value`
method.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-01 11:45:38 +03:00

27 lines
611 B
Go

package config_test
import (
"testing"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
"github.com/stretchr/testify/require"
)
func TestConfigCommon(t *testing.T) {
configtest.ForEachFileType("test/config", func(c *config.Config) {
val := c.Value("value")
require.NotNil(t, val)
val = c.Value("non-existent value")
require.Nil(t, val)
sub := c.Sub("section")
require.NotNil(t, sub)
const nonExistentSub = "non-existent sub-section"
val = c.Sub(nonExistentSub).Value("value")
require.Nil(t, val)
})
}