mqtt: increase test coverage for driver
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
868198d2aa
commit
eb4ce6bda5
|
@ -26,3 +26,27 @@ func TestMqttDriverName(t *testing.T) {
|
|||
d.SetName("NewName")
|
||||
gobottest.Assert(t, d.Name(), "NewName")
|
||||
}
|
||||
|
||||
func TestMqttDriverTopic(t *testing.T) {
|
||||
d := NewDriver(initTestMqttAdaptor(), "/test/topic")
|
||||
gobottest.Assert(t, d.Topic(), "/test/topic")
|
||||
d.SetTopic("/test/newtopic")
|
||||
gobottest.Assert(t, d.Topic(), "/test/newtopic")
|
||||
}
|
||||
|
||||
func TestMqttDriverPublish(t *testing.T) {
|
||||
a := initTestMqttAdaptor()
|
||||
d := NewDriver(a, "/test/topic")
|
||||
a.Connect()
|
||||
d.Start()
|
||||
defer d.Halt()
|
||||
gobottest.Assert(t, d.Publish([]byte{0x01, 0x02, 0x03}), true)
|
||||
}
|
||||
|
||||
func TestMqttDriverPublishError(t *testing.T) {
|
||||
a := initTestMqttAdaptor()
|
||||
d := NewDriver(a, "/test/topic")
|
||||
d.Start()
|
||||
defer d.Halt()
|
||||
gobottest.Assert(t, d.Publish([]byte{0x01, 0x02, 0x03}), false)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue