We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d7edea4 commit ba4da53Copy full SHA for ba4da53
example_function_test.go
@@ -1,26 +1,31 @@
1
package logrus_test
2
3
import (
4
- "fmt"
5
- log "github.com/sirupsen/logrus"
6
"testing"
+
+ log "github.com/sirupsen/logrus"
7
+ "github.com/stretchr/testify/assert"
8
)
9
10
func TestLogger_LogFn(t *testing.T) {
11
log.SetFormatter(&log.JSONFormatter{})
12
log.SetLevel(log.WarnLevel)
13
14
+ notCalled := 0
15
log.InfoFn(func() []interface{} {
- fmt.Println("This is never run")
- return []interface{} {
16
+ notCalled++
17
+ return []interface{}{
18
"Hello",
19
}
20
})
21
+ assert.Equal(t, 0, notCalled)
22
23
+ called := 0
24
log.ErrorFn(func() []interface{} {
- fmt.Println("This runs")
25
+ called++
26
27
"Oopsi",
28
29
30
+ assert.Equal(t, 1, called)
31
0 commit comments