MCPcopy Create free account
hub / github.com/DoNewsCode/core / TestWithContext

Function TestWithContext

logging/log_test.go:43–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestWithContext(t *testing.T) {
44 ctx := context.Background()
45 bag, ctx := ctxmeta.Inject(ctx)
46 bag.Set("foo", "bar")
47
48 var buf bytes.Buffer
49 l := log.NewLogfmtLogger(&buf)
50 ll := WithContext(l, ctx)
51 ll.Log("baz", "qux")
52 assert.Contains(t, buf.String(), "foo=bar baz=qux")
53}
54
55type mockSpan struct {
56 received []interface{}

Callers

nothing calls this directly

Calls 5

InjectFunction · 0.92
WithContextFunction · 0.85
LogMethod · 0.80
StringMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected