(t *testing.T)
| 543 | } |
| 544 | |
| 545 | func TestSlogHandler_TimestampWithoutHook(t *testing.T) { |
| 546 | var buf bytes.Buffer |
| 547 | // Logger without Timestamp() hook - Handle should add the timestamp |
| 548 | zl := zerolog.New(&buf) |
| 549 | handler := zerolog.NewSlogHandler(zl) |
| 550 | |
| 551 | ts := time.Date(2024, 6, 15, 12, 0, 0, 0, time.UTC) |
| 552 | record := slog.NewRecord(ts, slog.LevelInfo, "test", 0) |
| 553 | _ = handler.Handle(context.Background(), record) |
| 554 | |
| 555 | m := decodeJSON(t, &buf) |
| 556 | if m[zerolog.TimestampFieldName] == nil { |
| 557 | t.Error("expected timestamp field when logger has no timestamp hook") |
| 558 | } |
| 559 | } |
nothing calls this directly
no test coverage detected