Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Bryndin committed Mar 31, 2017
1 parent 70688fb commit c73ffea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions logrus_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"os/exec"
"testing"

"errors"

"github.com/Sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -144,6 +146,14 @@ func TestWithFields(t *testing.T) {
})
}

func TestWithError(t *testing.T) {
err := errors.New("test error")
logAndValidate(t, func(barkLogger bark.Logger, logrusLogger *logrus.Logger) {
barkLogger.WithError(err).Info("witherror")
logrusLogger.WithError(err).Info("witherror")
})
}

func TestGetFields(t *testing.T) {
var logger bark.Logger

Expand Down Expand Up @@ -194,6 +204,12 @@ func TestGetFields(t *testing.T) {
logger = bark.NewLoggerFromLogrus(logrus.New())
logger = logger.WithFields(bark.Fields{})
require.Equal(t, logger.Fields(), bark.Fields{})

// Add error
err := errors.New("test error")
logger = bark.NewLoggerFromLogrus(logrus.New())
logger = logger.WithError(err)
require.Equal(t, logger.Fields(), bark.Fields{logrus.ErrorKey: err})
}

func doPanic(t *testing.T, panicker func(...interface{})) {
Expand Down

0 comments on commit c73ffea

Please sign in to comment.