From 5847e1d9eeb7055c05724806a784bda9b2e41150 Mon Sep 17 00:00:00 2001 From: Sven Rebhan <36194019+srebhan@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:38:55 +0100 Subject: [PATCH] test(config): Add unit-test for comments in arrays (#14875) --- config/config_test.go | 9 +++++++++ config/testdata/single_plugin_with_comment_in_array.toml | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 config/testdata/single_plugin_with_comment_in_array.toml diff --git a/config/config_test.go b/config/config_test.go index 97644ac3f..6e427cb89 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -193,6 +193,15 @@ func TestConfig_LoadSingleInput_WithSeparators(t *testing.T) { require.Equal(t, inputConfig, c.Inputs[0].Config, "Testdata did not produce correct memcached metadata.") } +func TestConfig_LoadSingleInput_WithCommentInArray(t *testing.T) { + c := config.NewConfig() + require.NoError(t, c.LoadConfig("./testdata/single_plugin_with_comment_in_array.toml")) + require.Len(t, c.Inputs, 1) + + input := c.Inputs[0].Input.(*MockupInputPlugin) + require.ElementsMatch(t, input.Servers, []string{"localhost"}) +} + func TestConfig_LoadDirectory(t *testing.T) { c := config.NewConfig() diff --git a/config/testdata/single_plugin_with_comment_in_array.toml b/config/testdata/single_plugin_with_comment_in_array.toml new file mode 100644 index 000000000..d97c6f346 --- /dev/null +++ b/config/testdata/single_plugin_with_comment_in_array.toml @@ -0,0 +1,5 @@ +[[inputs.memcached]] + servers = [ + # A comment in the array + "localhost" + ]