✨ Separate formatters in config
This commit is contained in:
parent
99f6dc3f8c
commit
da3b524925
6 changed files with 56 additions and 11 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue