forked from lileio/logr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogr_test.go
35 lines (29 loc) · 804 Bytes
/
logr_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package logr_test
import (
"context"
"testing"
"github.com/lileio/logr"
"github.com/lileio/logr/logrfakes"
opentracing "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/mocktracer"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
func TestLogr(t *testing.T) {
l := logr.WithCtx(context.Background())
assert.NotNil(t, l)
}
func TestLogrWithZipkinContext(t *testing.T) {
tracer := mocktracer.New()
opentracing.SetGlobalTracer(tracer)
span := tracer.StartSpan("test_logger")
ctx := opentracing.ContextWithSpan(context.Background(), span)
fl := &logrfakes.FakeFieldLogger{}
fl.WithFieldsReturns(logrus.WithFields(logrus.Fields{
"animal": "walrus",
}))
l := logr.WithCtx(ctx)
l.Logger = fl
l.Infof(":aasdasd")
assert.NotNil(t, l)
}