[#577] cmd/node: Add tests for boolean type casting in config

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-01 19:24:44 +03:00 committed by Alex Vanin
parent ed80f704d0
commit 52c82ef46a
3 changed files with 33 additions and 0 deletions

View file

@ -63,6 +63,25 @@ func TestDuration(t *testing.T) {
})
}
func TestBool(t *testing.T) {
configtest.ForEachFileType("test/config", func(c *config.Config) {
c = c.Sub("bool")
val := config.Bool(c, "correct")
require.Equal(t, true, val)
val = config.Bool(c, "correct_string")
require.Equal(t, true, val)
require.Panics(t, func() {
config.Bool(c, "incorrect")
})
val = config.BoolSafe(c, "incorrect")
require.Equal(t, false, val)
})
}
func TestNumbers(t *testing.T) {
configtest.ForEachFileType("test/config", func(c *config.Config) {
c = c.Sub("number")