2017-02-01 04:13:35 +08:00
|
|
|
package nats
|
|
|
|
|
|
|
|
import (
|
2017-02-02 23:30:15 +08:00
|
|
|
"strings"
|
2017-02-01 04:13:35 +08:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/gobottest"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ gobot.Driver = (*Driver)(nil)
|
|
|
|
|
|
|
|
func TestNatsDriver(t *testing.T) {
|
|
|
|
d := NewDriver(initTestNatsAdaptor(), "/test/topic")
|
|
|
|
|
2017-02-02 23:30:15 +08:00
|
|
|
gobottest.Assert(t, strings.HasPrefix(d.Name(), "NATS"), true)
|
|
|
|
gobottest.Assert(t, strings.HasPrefix(d.Connection().Name(), "NATS"), true)
|
2017-04-29 19:40:27 +08:00
|
|
|
gobottest.Refute(t, d.adaptor(), nil)
|
2017-02-01 04:13:35 +08:00
|
|
|
|
|
|
|
gobottest.Assert(t, d.Start(), nil)
|
|
|
|
gobottest.Assert(t, d.Halt(), nil)
|
|
|
|
}
|
2017-04-06 16:56:49 +08:00
|
|
|
|
|
|
|
func TestNatsDriverName(t *testing.T) {
|
|
|
|
d := NewDriver(initTestNatsAdaptor(), "/test/topic")
|
|
|
|
gobottest.Assert(t, strings.HasPrefix(d.Name(), "NATS"), true)
|
|
|
|
d.SetName("NewName")
|
|
|
|
gobottest.Assert(t, d.Name(), "NewName")
|
|
|
|
}
|
2017-04-29 19:40:27 +08:00
|
|
|
|
|
|
|
func TestNatsDriverTopic(t *testing.T) {
|
|
|
|
d := NewDriver(initTestNatsAdaptor(), "/test/topic")
|
|
|
|
d.SetTopic("interestingtopic")
|
|
|
|
gobottest.Assert(t, d.Topic(), "interestingtopic")
|
|
|
|
}
|