diff options
| author | junya koyama <arukiidou@yahoo.co.jp> | 2025-03-23 10:04:50 +0000 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2025-03-25 19:19:09 -0700 |
| commit | 99d97d7c4f2c2bb0df30f0ca79924754b3b424ec (patch) | |
| tree | d220ec575d123c274d8bec5d0702dd0018677a97 /src | |
| parent | 0095b5d09885390505e679aafee8f3e525b33c9d (diff) | |
| download | go-99d97d7c4f2c2bb0df30f0ca79924754b3b424ec.tar.xz | |
testing/slogtest: test nested groups in empty record
Updates #62280
Change-Id: I1c80cb18bb174b47ff156974f72c37baf6b73635
GitHub-Last-Rev: d98b6cd57eb028af8513f583cbef3ce46505b590
GitHub-Pull-Request: golang/go#65597
Reviewed-on: https://go-review.googlesource.com/c/go/+/562635
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Diffstat (limited to 'src')
| -rw-r--r-- | src/testing/slogtest/slogtest.go | 16 |
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) { |
