mqtt: increase test coverage for driver

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-04-19 10:59:33 +02:00
parent 868198d2aa
commit eb4ce6bda5
1 changed files with 24 additions and 0 deletions

View File

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