MCPcopy
hub / github.com/uber-go/zap / TestConsoleSeparator

Function TestConsoleSeparator

zapcore/console_encoder_test.go:84–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestConsoleSeparator(t *testing.T) {
85 tests := []struct {
86 desc string
87 separator string
88 wantConsole string
89 }{
90 {
91 desc: "space console separator",
92 separator: " ",
93 wantConsole: "0 info main foo.go:42 foo.Foo hello\nfake-stack\n",
94 },
95 {
96 desc: "default console separator",
97 separator: "",
98 wantConsole: "0\tinfo\tmain\tfoo.go:42\tfoo.Foo\thello\nfake-stack\n",
99 },
100 {
101 desc: "tag console separator",
102 separator: "\t",
103 wantConsole: "0\tinfo\tmain\tfoo.go:42\tfoo.Foo\thello\nfake-stack\n",
104 },
105 {
106 desc: "dash console separator",
107 separator: "--",
108 wantConsole: "0--info--main--foo.go:42--foo.Foo--hello\nfake-stack\n",
109 },
110 }
111
112 for _, tt := range tests {
113 console := NewConsoleEncoder(encoderTestEncoderConfig(tt.separator))
114 t.Run(tt.desc, func(t *testing.T) {
115 entry := testEntry
116 consoleOut, err := console.EncodeEntry(entry, nil)
117 if !assert.NoError(t, err) {
118 return
119 }
120 assert.Equal(
121 t,
122 tt.wantConsole,
123 consoleOut.String(),
124 "Unexpected console output",
125 )
126 })
127
128 }
129}
130
131func encoderTestEncoderConfig(separator string) EncoderConfig {
132 testEncoder := testEncoderConfig()

Callers

nothing calls this directly

Calls 4

NewConsoleEncoderFunction · 0.85
encoderTestEncoderConfigFunction · 0.85
EncodeEntryMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected