[refactor] Use protobuf messages

This commit is contained in:
2020-01-01 20:33:41 +01:00
parent 7b0cb1c71f
commit 7da813e837
29 changed files with 12643 additions and 66 deletions

View File

@ -3,6 +3,8 @@ package testtools
import (
"github.com/cyrilix/robocar-base/mqttdevice"
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/golang/protobuf/proto"
log "github.com/sirupsen/logrus"
"sync"
)
@ -71,3 +73,12 @@ func NewFakeMessage(topic string, payload []byte) mqtt.Message {
acked: false,
}
}
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)
return nil
}
return NewFakeMessage(topic, payload)
}