aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/slogtest/slogtest.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/testing/slogtest/slogtest.go b/src/testing/slogtest/slogtest.go
index f9e2d90041..7378b0613d 100644
--- a/src/testing/slogtest/slogtest.go
+++ b/src/testing/slogtest/slogtest.go
@@ -172,6 +172,22 @@ var cases = []testCase{
},
},
{
+ name: "nested-empty-group-record",
+ explanation: withSource("a Handler should not output nested groups if there are no attributes"),
+ f: func(l *slog.Logger) {
+ l.With("a", "b").WithGroup("G").With("c", "d").WithGroup("H").WithGroup("I").Info("msg")
+ },
+ checks: []check{
+ hasKey(slog.TimeKey),
+ hasKey(slog.LevelKey),
+ hasAttr(slog.MessageKey, "msg"),
+ hasAttr("a", "b"),
+ inGroup("G", hasAttr("c", "d")),
+ inGroup("G", missingKey("H")),
+ inGroup("G", missingKey("I")),
+ },
+ },
+ {
name: "resolve",
explanation: withSource("a Handler should call Resolve on attribute values"),
f: func(l *slog.Logger) {