forked from TrueCloudLab/frostfs-node
1aa88159ca
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>
27 lines
611 B
Go
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)
|
|
})
|
|
}
|