blob: c63f9cd0a49502740e9319b1975c60774df51b52 [file] [log] [blame]
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package elogr
import (
"context"
"testing"
"github.com/google/go-cmp/cmp"
"golang.org/x/exp/event"
"golang.org/x/exp/event/keys"
"golang.org/x/exp/event/logging/internal"
)
func TestInfo(t *testing.T) {
e, th := internal.NewTestExporter()
log := NewLogger(event.WithExporter(context.Background(), e), "/").WithName("n").V(3)
log = log.WithName("m")
log.Info("mess", "traceID", 17, "resource", "R")
want := &event.Event{
At: internal.TestAt,
Labels: []event.Label{
internal.LevelKey.Of(3),
internal.NameKey.Of("n/m"),
keys.Value("traceID").Of(17),
keys.Value("resource").Of("R"),
event.Message.Of("mess"),
},
}
if diff := cmp.Diff(want, &th.Got); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
}
}