Separate formatters in config

This commit is contained in:
Dan Jones 2024-03-07 21:19:45 -06:00
commit da3b524925
6 changed files with 56 additions and 11 deletions

View file

@ -65,12 +65,25 @@ func TestStdoutMissing(t *testing.T) {
}
func TestStdoutLoad(t *testing.T) {
os.Setenv("LOG_STDOUT_JSON", "true")
defer os.Unsetenv("LOG_STDOUT_JSON")
os.Setenv("LOG_STDOUT_FORMATTER", "json")
defer os.Unsetenv("LOG_STDOUT_FORMATTER")
os.Setenv("LOG_STDOUT_ENABLED", "true")
defer os.Unsetenv("LOG_STDOUT_ENABLED")
c, _ := Load()
std, en := c.Outputs.Stdout()
assert.True(t, en)
assert.True(t, std.Json)
assert.Equal(t, "json", std.Formatter)
}
func TestFormatJson(t *testing.T) {
ff := Formatters{
"json": map[string]any{"pretty_print": true},
}
js := ff.Json()
assert.True(t, js.PrettyPrint)
ff = Formatters{}
js = ff.Json()
assert.False(t, js.PrettyPrint)
}