refactor: replace logrus logger with zap

This commit is contained in:
2021-10-12 23:39:07 +02:00
parent 6cf77035fe
commit 92f9239d29
419 changed files with 38409 additions and 23342 deletions

View File

@ -9,29 +9,29 @@ import (
)
func MqttContainer(t *testing.T) (context.Context, testcontainers.Container, string) {
ctx := context.Background()
req := testcontainers.ContainerRequest{
Image: "eclipse-mosquitto",
ExposedPorts: []string{"1883/tcp"},
WaitingFor: wait.ForLog("listen socket on port 1883."),
}
mqttC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
})
if err != nil {
t.Error(err)
}
ctx := context.Background()
req := testcontainers.ContainerRequest{
Image: "eclipse-mosquitto",
ExposedPorts: []string{"1883/tcp"},
WaitingFor: wait.ForLog("listen socket on port 1883."),
}
mqttC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
})
if err != nil {
t.Error(err)
}
ip, err := mqttC.Host(ctx)
if err != nil {
t.Error(err)
}
port, err := mqttC.MappedPort(ctx, "1883/tcp")
if err != nil {
t.Error(err)
}
ip, err := mqttC.Host(ctx)
if err != nil {
t.Error(err)
}
port, err := mqttC.MappedPort(ctx, "1883/tcp")
if err != nil {
t.Error(err)
}
mqttUri := fmt.Sprintf("tcp://%s:%d", ip, port.Int())
return ctx, mqttC, mqttUri
mqttUri := fmt.Sprintf("tcp://%s:%d", ip, port.Int())
return ctx, mqttC, mqttUri
}

View File

@ -3,7 +3,7 @@ package testtools
import (
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/golang/protobuf/proto"
log "github.com/sirupsen/logrus"
"go.uber.org/zap"
)
type fakeMessage struct {
@ -50,10 +50,10 @@ func NewFakeMessage(topic string, payload []byte) mqtt.Message {
}
}
func NewFakeMessageFromProtobuf(topic string, msg proto.Message) mqtt.Message{
func NewFakeMessageFromProtobuf(topic string, msg proto.Message) mqtt.Message {
payload, err := proto.Marshal(msg)
if err != nil {
log.Errorf("unable to marshal protobuf message %T: %v", msg, err)
if err != nil {
zap.S().Errorf("unable to marshal protobuf message %T: %v", msg, err)
return nil
}
return NewFakeMessage(topic, payload)