From 2b8750b239b8d6d6e38455e51cebd843ffd5087c Mon Sep 17 00:00:00 2001 From: deadprogram Date: Thu, 6 Apr 2017 10:56:49 +0200 Subject: [PATCH] nats: increase test coverage Signed-off-by: deadprogram --- platforms/nats/nats_adaptor_test.go | 11 ++++++++++- platforms/nats/nats_driver_test.go | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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") +}