MCPcopy
hub / github.com/kopia/kopia / TestLog6

Function TestLog6

internal/contentlog/contentlog_logger_test.go:301–334  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

299}
300
301func TestLog6(t *testing.T) {
302 t.Run("logs message with six parameters", func(t *testing.T) {
303 var captured []byte
304
305 outputFunc := func(data []byte) {
306 captured = append(captured, data...)
307 }
308
309 logger := contentlog.NewLogger(outputFunc)
310 ctx := context.Background()
311
312 contentlog.Log6(ctx, logger, "processing item",
313 logparam.String("id", "item-123"),
314 logparam.Int("count", 5),
315 logparam.Bool("active", true),
316 logparam.String("status", "processing"),
317 logparam.Int64("size", 1024),
318 logparam.UInt64("flags", 0xFF))
319
320 require.NotEmpty(t, captured)
321
322 var logEntry map[string]any
323
324 err := json.Unmarshal(captured, &logEntry)
325 require.NoError(t, err)
326 require.Equal(t, "processing item", logEntry["m"])
327 require.Equal(t, "item-123", logEntry["id"])
328 require.Equal(t, float64(5), logEntry["count"])
329 require.Equal(t, true, logEntry["active"])
330 require.Equal(t, "processing", logEntry["status"])
331 require.Equal(t, float64(1024), logEntry["size"])
332 require.Equal(t, float64(0xFF), logEntry["flags"])
333 })
334}
335
336func TestEmit(t *testing.T) {
337 t.Run("emits custom WriterTo entry", func(t *testing.T) {

Callers

nothing calls this directly

Calls 9

NewLoggerFunction · 0.92
Log6Function · 0.92
StringFunction · 0.92
IntFunction · 0.92
BoolFunction · 0.92
Int64Function · 0.92
UInt64Function · 0.92
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected