1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00

nats: increase test coverage

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-04-06 10:56:49 +02:00
parent 1e7deaed7d
commit 2b8750b239
2 changed files with 17 additions and 1 deletions

View File

@ -3,10 +3,12 @@ package nats
import (
"errors"
"fmt"
"strings"
"testing"
"github.com/nats-io/nats"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
"testing"
)
var _ gobot.Adaptor = (*Adaptor)(nil)
@ -39,6 +41,13 @@ func initTestNatsAdaptorTLS(options ...nats.Option) *Adaptor {
return a
}
func TestNatsAdaptorName(t *testing.T) {
a := initTestNatsAdaptor()
gobottest.Assert(t, strings.HasPrefix(a.Name(), "NATS"), true)
a.SetName("NewName")
gobottest.Assert(t, a.Name(), "NewName")
}
func TestNatsAdaptorReturnsHost(t *testing.T) {
a := initTestNatsAdaptor()
gobottest.Assert(t, a.Host, "nats://localhost:4222")

View File

@ -19,3 +19,10 @@ func TestNatsDriver(t *testing.T) {
gobottest.Assert(t, d.Start(), nil)
gobottest.Assert(t, d.Halt(), nil)
}
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")
}