[testtools] Add utility method to generate fake mqtt message
This commit is contained in:
@@ -9,16 +9,16 @@ func TestFakePublisher_Publish(t *testing.T) {
|
||||
p := NewFakePublisher()
|
||||
|
||||
cases := []struct {
|
||||
topic string
|
||||
topic string
|
||||
topicPublished string
|
||||
value mqttdevice.MqttValue
|
||||
expected string
|
||||
value mqttdevice.MqttValue
|
||||
expected string
|
||||
}{
|
||||
{"test/topic1", "test/topic1", mqttdevice.NewMqttValue(1) , "1" },
|
||||
{"test/topic2", "test/invalid", mqttdevice.NewMqttValue(1) , "" },
|
||||
{"test/topic1", "test/topic1", mqttdevice.NewMqttValue(1), "1"},
|
||||
{"test/topic2", "test/invalid", mqttdevice.NewMqttValue(1), ""},
|
||||
}
|
||||
|
||||
for _, c := range cases{
|
||||
for _, c := range cases {
|
||||
p.Publish(c.topic, c.value)
|
||||
val := p.PublishedEvent(c.topicPublished)
|
||||
if v, _ := val.StringValue(); v != c.expected {
|
||||
|
||||
Reference in New Issue
Block a user