-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnsqd_test.go
48 lines (40 loc) · 947 Bytes
/
nsqd_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
40
41
42
43
44
45
46
47
48
//nolint: paralleltest
package log_test
import (
"bytes"
"testing"
log "github.com/spacetab-io/logs-go/v2"
"github.com/stretchr/testify/assert"
)
func TestNSQLogger_Output(t *testing.T) {
type tc struct {
name string
in string
exp string
}
tcs := []tc{
{
name: "NSQ error log",
in: "ERR 1 (localhost:4150) error connecting to nsqd - dial tcp [::1]:4150: connect: connection refused",
exp: "1 (localhost:4150) error connecting to nsqd - dial tcp [::1]:4150: connect: connection refused",
},
{
name: "uncommon err",
in: "some log",
exp: "some log",
},
}
for _, tc := range tcs {
tc := tc
t.Run(tc.name, func(t *testing.T) {
out := &bytes.Buffer{}
_ = initLog(out)
nsqdLogger := log.NewNSQLogger("info")
err := nsqdLogger.Output(2, tc.in)
if !assert.NoError(t, err, "nsqdLogger.Output error") {
t.FailNow()
}
assert.Contains(t, out.String(), tc.exp)
})
}
}