diff --git a/cmd/neofs-node/config/cast_test.go b/cmd/neofs-node/config/cast_test.go index 9111f295e2..b6ea84d2ff 100644 --- a/cmd/neofs-node/config/cast_test.go +++ b/cmd/neofs-node/config/cast_test.go @@ -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") diff --git a/cmd/neofs-node/config/test/config.json b/cmd/neofs-node/config/test/config.json index e2d00fcab0..81bae1cdb8 100644 --- a/cmd/neofs-node/config/test/config.json +++ b/cmd/neofs-node/config/test/config.json @@ -23,19 +23,28 @@ ], "incorrect": null }, + "string": { "correct": "some string", "incorrect": [] }, + "duration": { "correct": "15m", "incorrect": "some string" }, + "number": { "int_pos": 1, "int_neg": -1, "fract_pos": 2.5, "fract_neg": -2.5, "incorrect": "some string" + }, + + "bool": { + "correct": true, + "correct_string": "true", + "incorrect": "not true" } } diff --git a/cmd/neofs-node/config/test/config.yaml b/cmd/neofs-node/config/test/config.yaml index 6ee4aca0f2..2b080977bb 100644 --- a/cmd/neofs-node/config/test/config.yaml +++ b/cmd/neofs-node/config/test/config.yaml @@ -35,3 +35,8 @@ number: fract_pos: 2.5 fract_neg: -2.5 incorrect: some string + +bool: + correct: true + correct_string: "true" + incorrect: not true