test(config): Add unit-test for comments in arrays (#14875)

This commit is contained in:
Sven Rebhan 2024-02-22 18:38:55 +01:00 committed by GitHub
parent 4dea65d1ea
commit 5847e1d9ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -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()

View File

@ -0,0 +1,5 @@
[[inputs.memcached]]
servers = [
# A comment in the array
"localhost"
]