Add WithContext

This commit is contained in:
Adam Renberg Tamm
2019-03-11 11:47:03 +01:00
parent d7b6bf5e4d
commit 68e41f673a
4 changed files with 40 additions and 2 deletions
+14
View File
@@ -2,6 +2,7 @@ package logrus
import (
"bytes"
"context"
"fmt"
"testing"
"time"
@@ -33,6 +34,19 @@ func TestEntryWithError(t *testing.T) {
}
func TestEntryWithContext(t *testing.T) {
assert := assert.New(t)
ctx := context.WithValue(context.Background(), "foo", "bar")
assert.Equal(ctx, WithContext(ctx).Context)
logger := New()
logger.Out = &bytes.Buffer{}
entry := NewEntry(logger)
assert.Equal(ctx, entry.WithContext(ctx).Context)
}
func TestEntryPanicln(t *testing.T) {
errBoom := fmt.Errorf("boom time")