| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package logr_test |
| 8 |
|
| 9 |
import ( |
| 10 |
"testing" |
| 11 |
|
| 12 |
"github.com/google/go-cmp/cmp" |
| 13 |
"golang.org/x/exp/event" |
| 14 |
elogr "golang.org/x/exp/event/adapter/logr" |
| 15 |
"golang.org/x/exp/event/eventtest" |
| 16 |
"golang.org/x/exp/event/severity" |
| 17 |
) |
| 18 |
|
| 19 |
func TestInfo(t *testing.T) { |
| 20 |
ctx, th := eventtest.NewCapture() |
| 21 |
log := elogr.NewLogger(ctx, "/").WithName("n").V(int(severity.Debug)) |
| 22 |
log = log.WithName("m") |
| 23 |
log.Info("mess", "traceID", 17, "resource", "R") |
| 24 |
want := []event.Event{{ |
| 25 |
ID: 1, |
| 26 |
Kind: event.LogKind, |
| 27 |
Labels: []event.Label{ |
| 28 |
severity.Debug.Label(), |
| 29 |
event.Value("traceID", 17), |
| 30 |
event.Value("resource", "R"), |
| 31 |
event.String("name", "n/m"), |
| 32 |
event.String("msg", "mess"), |
| 33 |
}, |
| 34 |
}} |
| 35 |
if diff := cmp.Diff(want, th.Got, eventtest.CmpOptions()...); diff != "" { |
| 36 |
t.Errorf("mismatch (-want, +got):\n%s", diff) |
| 37 |
} |
| 38 |
} |