mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-22 15:30:59 +00:00
Add noplogger to tests
Signed-off-by: mhartenbower <matt.hartenbower@gmail.com>
This commit is contained in:
parent
c710b851c7
commit
5f4f780e16
3 changed files with 8 additions and 3 deletions
|
@ -16,6 +16,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-kit/kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHandlePacket(t *testing.T) {
|
func TestHandlePacket(t *testing.T) {
|
||||||
|
@ -413,7 +415,7 @@ func TestHandlePacket(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, l := range []statsDPacketHandler{&StatsDUDPListener{}, &mockStatsDTCPListener{}} {
|
for k, l := range []statsDPacketHandler{&StatsDUDPListener{nil, nil, log.NewNopLogger()}, &mockStatsDTCPListener{StatsDTCPListener{nil, nil, log.NewNopLogger()}, log.NewNopLogger()}} {
|
||||||
events := make(chan Events, 32)
|
events := make(chan Events, 32)
|
||||||
l.SetEventHandler(&unbufferedEventHandler{c: events})
|
l.SetEventHandler(&unbufferedEventHandler{c: events})
|
||||||
for i, scenario := range scenarios {
|
for i, scenario := range scenarios {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -581,7 +582,8 @@ func (l *StatsDUnixgramListener) Listen() {
|
||||||
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
panic(err)
|
level.Error(l.logger).Log(err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
l.handlePacket(buf[:n])
|
l.handlePacket(buf[:n])
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,7 +493,7 @@ func TestInvalidUtf8InDatadogTagValue(t *testing.T) {
|
||||||
ueh := &unbufferedEventHandler{c: events}
|
ueh := &unbufferedEventHandler{c: events}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for _, l := range []statsDPacketHandler{&StatsDUDPListener{}, &mockStatsDTCPListener{}} {
|
for _, l := range []statsDPacketHandler{&StatsDUDPListener{nil, nil, log.NewNopLogger()}, &mockStatsDTCPListener{StatsDTCPListener{nil, nil, log.NewNopLogger()}, log.NewNopLogger()}} {
|
||||||
l.SetEventHandler(ueh)
|
l.SetEventHandler(ueh)
|
||||||
l.handlePacket([]byte("bar:200|c|#tag:value\nbar:200|c|#tag:\xc3\x28invalid"))
|
l.handlePacket([]byte("bar:200|c|#tag:value\nbar:200|c|#tag:\xc3\x28invalid"))
|
||||||
}
|
}
|
||||||
|
@ -648,6 +648,7 @@ type statsDPacketHandler interface {
|
||||||
|
|
||||||
type mockStatsDTCPListener struct {
|
type mockStatsDTCPListener struct {
|
||||||
StatsDTCPListener
|
StatsDTCPListener
|
||||||
|
log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ml *mockStatsDTCPListener) handlePacket(packet []byte) {
|
func (ml *mockStatsDTCPListener) handlePacket(packet []byte) {
|
||||||
|
|
Loading…
Reference in a new issue