]> Cypherpunks repositories - gostls13.git/commitdiff
testing/slogtest: test no source key with empty PC in record
authorNakul Bajaj <nbajaj@umich.edu>
Wed, 18 Oct 2023 06:24:20 +0000 (23:24 -0700)
committerJonathan Amsterdam <jba@google.com>
Tue, 24 Oct 2023 15:06:07 +0000 (15:06 +0000)
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>
src/testing/slogtest/slogtest.go

index e60e8438d4972903ae804367a2acf74385ef17f1..6f08180df59f4238cbc5c8b467dd9b703ff55c67 100644 (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].