-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_test.go
39 lines (33 loc) · 881 Bytes
/
log_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
36
37
38
39
package otfranz
import (
"bytes"
"testing"
"github.com/go-kit/log"
"github.com/stretchr/testify/assert"
"github.com/twmb/franz-go/pkg/kgo"
)
func Test_logAdapter(t *testing.T) {
cases := []struct {
name string
lvlCfg string
level kgo.LogLevel
want string
}{
{"debug-debug", "debug", kgo.LogLevelDebug, "msg=foo\n"},
{"debug-info", "debug", kgo.LogLevelInfo, "msg=foo\n"},
{"info-debug", "info", kgo.LogLevelDebug, ""},
{"info-info", "info", kgo.LogLevelInfo, "msg=foo\n"},
{"warn", "warn", kgo.LogLevelWarn, "msg=foo\n"},
{"error", "error", kgo.LogLevelError, "msg=foo\n"},
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
buf := bytes.NewBuffer(nil)
logger := FranzLogAdapter(c.lvlCfg, log.NewLogfmtLogger(buf))
logger.Log(c.level, "foo")
assert.Equal(t, c.want, buf.String())
})
}
}