1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-14 19:29:32 +08:00
hybridgroup.gobot/platforms/mqtt/mqtt_driver_test.go
deadprogram 1e7deaed7d mqtt: increase test coverage
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-04-06 10:55:06 +02:00

29 lines
669 B
Go

package mqtt
import (
"strings"
"testing"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
)
var _ gobot.Driver = (*Driver)(nil)
func TestMqttDriver(t *testing.T) {
d := NewDriver(initTestMqttAdaptor(), "/test/topic")
gobottest.Assert(t, strings.HasPrefix(d.Name(), "MQTT"), true)
gobottest.Assert(t, strings.HasPrefix(d.Connection().Name(), "MQTT"), true)
gobottest.Assert(t, d.Start(), nil)
gobottest.Assert(t, d.Halt(), nil)
}
func TestMqttDriverName(t *testing.T) {
d := NewDriver(initTestMqttAdaptor(), "/test/topic")
gobottest.Assert(t, strings.HasPrefix(d.Name(), "MQTT"), true)
d.SetName("NewName")
gobottest.Assert(t, d.Name(), "NewName")
}