diff options
| author | Nakul Bajaj <nbajaj@umich.edu> | 2023-10-17 23:24:20 -0700 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2023-10-24 15:06:07 +0000 |
| commit | 983d90e11dd0e12a484def454530fe9f5de031fc (patch) | |
| tree | 62833d53e9e16644a023f960d5c685a2e071d3f5 /src | |
| parent | 6f87db509a929026ff48a47180f4ec832afc4a86 (diff) | |
| download | go-983d90e11dd0e12a484def454530fe9f5de031fc.tar.xz | |
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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/testing/slogtest/slogtest.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/testing/slogtest/slogtest.go b/src/testing/slogtest/slogtest.go index e60e8438d4..6f08180df5 100644 --- a/src/testing/slogtest/slogtest.go +++ b/src/testing/slogtest/slogtest.go @@ -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]. |
