forked from mirror/logrus
32 lines
496 B
Go
32 lines
496 B
Go
package logrus_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
log "git.internal/re/logrus"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLogger_LogFn(t *testing.T) {
|
|
log.SetFormatter(&log.JSONFormatter{})
|
|
log.SetLevel(log.WarnLevel)
|
|
|
|
notCalled := 0
|
|
log.InfoFn(func() []interface{} {
|
|
notCalled++
|
|
return []interface{}{
|
|
"Hello",
|
|
}
|
|
})
|
|
assert.Equal(t, 0, notCalled)
|
|
|
|
called := 0
|
|
log.ErrorFn(func() []interface{} {
|
|
called++
|
|
return []interface{}{
|
|
"Oopsi",
|
|
}
|
|
})
|
|
assert.Equal(t, 1, called)
|
|
}
|