gobot.io/x/gobot/v2@v2.1.0/platforms/nats/nats_driver_test.go (about) 1 package nats 2 3 import ( 4 "strings" 5 "testing" 6 7 "gobot.io/x/gobot/v2" 8 "gobot.io/x/gobot/v2/gobottest" 9 ) 10 11 var _ gobot.Driver = (*Driver)(nil) 12 13 func TestNatsDriver(t *testing.T) { 14 d := NewDriver(initTestNatsAdaptor(), "/test/topic") 15 16 gobottest.Assert(t, strings.HasPrefix(d.Name(), "NATS"), true) 17 gobottest.Assert(t, strings.HasPrefix(d.Connection().Name(), "NATS"), true) 18 gobottest.Refute(t, d.adaptor(), nil) 19 20 gobottest.Assert(t, d.Start(), nil) 21 gobottest.Assert(t, d.Halt(), nil) 22 } 23 24 func TestNatsDriverName(t *testing.T) { 25 d := NewDriver(initTestNatsAdaptor(), "/test/topic") 26 gobottest.Assert(t, strings.HasPrefix(d.Name(), "NATS"), true) 27 d.SetName("NewName") 28 gobottest.Assert(t, d.Name(), "NewName") 29 } 30 31 func TestNatsDriverTopic(t *testing.T) { 32 d := NewDriver(initTestNatsAdaptor(), "/test/topic") 33 d.SetTopic("interestingtopic") 34 gobottest.Assert(t, d.Topic(), "interestingtopic") 35 }