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