diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:41:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:41:39 +0000 |
commit | fcfb5e62f95d625836328131cc5ca851182bcae4 (patch) | |
tree | 5309ef2284a82d61ece838d1dd1c97c09df152b8 /pkg/config/config_test.go | |
parent | Adding upstream version 1.1.1. (diff) | |
download | icingadb-6ee3f6d80af8d7d56be5d07c1977df9f7da6f0ec.tar.xz icingadb-6ee3f6d80af8d7d56be5d07c1977df9f7da6f0ec.zip |
Adding upstream version 1.2.0.upstream/1.2.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pkg/config/config_test.go')
-rw-r--r-- | pkg/config/config_test.go | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 2418094..94e3773 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -20,34 +20,33 @@ redis: host: 2001:db8::1 ` - miniOutput := &Config{} - _ = defaults.Set(miniOutput) - - miniOutput.Database.Host = "192.0.2.1" - miniOutput.Database.Database = "icingadb" - miniOutput.Database.User = "icingadb" - miniOutput.Database.Password = "icingadb" - - miniOutput.Redis.Host = "2001:db8::1" - miniOutput.Logging.Output = logging.CONSOLE - subtests := []struct { name string input string output *Config - warn bool }{ { - name: "mini", - input: miniConf, - output: miniOutput, - warn: false, + name: "mini", + input: miniConf, + output: func() *Config { + c := &Config{} + _ = defaults.Set(c) + + c.Database.Host = "192.0.2.1" + c.Database.Database = "icingadb" + c.Database.User = "icingadb" + c.Database.Password = "icingadb" + + c.Redis.Host = "2001:db8::1" + c.Logging.Output = logging.CONSOLE + + return c + }(), }, { name: "mini-with-unknown", input: miniConf + "\nunknown: 42", - output: miniOutput, - warn: true, + output: nil, }, } @@ -59,19 +58,12 @@ redis: require.NoError(t, os.WriteFile(tempFile.Name(), []byte(st.input), 0o600)) - actual, err := FromYAMLFile(tempFile.Name()) - require.NoError(t, err) - - if st.warn { - require.Error(t, actual.DecodeWarning, "reading config should produce a warning") - - // Reset the warning so that the following require.Equal() doesn't try to compare it. - actual.DecodeWarning = nil + if actual, err := FromYAMLFile(tempFile.Name()); st.output == nil { + require.Error(t, err) } else { - require.NoError(t, actual.DecodeWarning, "reading config should not produce a warning") + require.NoError(t, err) + require.Equal(t, st.output, actual) } - - require.Equal(t, st.output, actual) }) } } |