diff --git a/platforms/nats/nats_adaptor_test.go b/platforms/nats/nats_adaptor_test.go index 262fdfd4..8aa631c0 100644 --- a/platforms/nats/nats_adaptor_test.go +++ b/platforms/nats/nats_adaptor_test.go @@ -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") diff --git a/platforms/nats/nats_driver_test.go b/platforms/nats/nats_driver_test.go index d0b58586..88511a36 100644 --- a/platforms/nats/nats_driver_test.go +++ b/platforms/nats/nats_driver_test.go @@ -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") +}