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

29 lines
669 B
Go
Raw Normal View History

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")
}