testing/slogtest: test no source key with empty PC in record

Fixes #62280

Change-Id: Ideaffb797d8bb9cc70e635f0b019ae3cb90abc92
Reviewed-on: https://go-review.googlesource.com/c/go/+/536117
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
Nakul Bajaj 2023-10-17 23:24:20 -07:00 committed by Jonathan Amsterdam
parent 6f87db509a
commit 983d90e11d
1 changed files with 11 additions and 0 deletions

View File

@ -216,6 +216,17 @@ var cases = []testCase{
inGroup("G", hasAttr("b", "v2")),
},
},
{
name: "empty-PC",
explanation: withSource("a Handler should not output SourceKey if the PC is zero"),
f: func(l *slog.Logger) {
l.Info("message")
},
mod: func(r *slog.Record) { r.PC = 0 },
checks: []check{
missingKey(slog.SourceKey),
},
},
}
// TestHandler tests a [slog.Handler].