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

Function TestLoggerWithCaptures

logger_test.go:178–373  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

176}
177
178func TestLoggerWithCaptures(t *testing.T) {
179 type withF func(*Logger, ...Field) *Logger
180 tests := []struct {
181 name string
182 withMethods []withF
183 wantJSON []string
184 }{
185 {
186 name: "regular with captures arguments at time of With",
187 withMethods: []withF{(*Logger).With},
188 wantJSON: []string{
189 `{
190 "m": "hello 0",
191 "a0": [0],
192 "b0": [1]
193 }`,
194 `{
195 "m": "world 0",
196 "a0": [0],
197 "c0": [2]
198 }`,
199 },
200 },
201 {
202 name: "lazy with captures arguments at time of With or Logging",
203 withMethods: []withF{(*Logger).WithLazy},
204 wantJSON: []string{
205 `{
206 "m": "hello 0",
207 "a0": [1],
208 "b0": [1]
209 }`,
210 `{
211 "m": "world 0",
212 "a0": [1],
213 "c0": [2]
214 }`,
215 },
216 },
217 {
218 name: "2x With captures arguments at time of each With",
219 withMethods: []withF{(*Logger).With, (*Logger).With},
220 wantJSON: []string{
221 `{
222 "m": "hello 0",
223 "a0": [0],
224 "b0": [1]
225 }`,
226 `{
227 "m": "world 0",
228 "a0": [0],
229 "c0": [2]
230 }`,
231 `{
232 "m": "hello 1",
233 "a0": [0],
234 "c0": [2],
235 "a1": [10],

Callers

nothing calls this directly

Calls 9

LinesMethod · 0.95
NewJSONEncoderFunction · 0.92
NewCoreFunction · 0.92
ArrayMarshalerFuncFuncType · 0.92
ArrayFunction · 0.85
NewFunction · 0.70
AppendIntMethod · 0.65
InfoMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected