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:
parent
1e7deaed7d
commit
2b8750b239
@ -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")
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user