Files
gluetun/internal/dns/logs_test.go

49 lines
1.2 KiB
Go
Raw Normal View History

2021-01-26 04:17:22 +00:00
package dns
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_processLogLine(t *testing.T) {
t.Parallel()
tests := map[string]struct {
s string
filtered string
2021-09-23 17:05:48 +00:00
level logLevel
2021-01-26 04:17:22 +00:00
}{
2021-09-23 17:05:48 +00:00
"empty string": {"", "", levelInfo},
"random string": {"asdasqdb", "asdasqdb", levelInfo},
2021-01-26 04:17:22 +00:00
"unbound notice": {
"[1594595249] unbound[75:0] notice: init module 0: validator",
"init module 0: validator",
2021-09-23 17:05:48 +00:00
levelInfo},
2021-01-26 04:17:22 +00:00
"unbound info": {
"[1594595249] unbound[75:0] info: init module 0: validator",
"init module 0: validator",
2021-09-23 17:05:48 +00:00
levelInfo},
2021-01-26 04:17:22 +00:00
"unbound warn": {
"[1594595249] unbound[75:0] warn: init module 0: validator",
"init module 0: validator",
2021-09-23 17:05:48 +00:00
levelWarn},
2021-01-26 04:17:22 +00:00
"unbound error": {
"[1594595249] unbound[75:0] error: init module 0: validator",
"init module 0: validator",
2021-09-23 17:05:48 +00:00
levelError},
2021-01-26 04:17:22 +00:00
"unbound unknown": {
"[1594595249] unbound[75:0] BLA: init module 0: validator",
"BLA: init module 0: validator",
2021-09-23 17:05:48 +00:00
levelInfo},
2021-01-26 04:17:22 +00:00
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
filtered, level := processLogLine(tc.s)
assert.Equal(t, tc.filtered, filtered)
assert.Equal(t, tc.level, level)
})
}
}