diff --git a/mqtttest/mqtttest.go b/mqtttest/mqtttest.go index 7c35b06..19ca241 100644 --- a/mqtttest/mqtttest.go +++ b/mqtttest/mqtttest.go @@ -11,19 +11,6 @@ import ( "github.com/pascaldekloe/mqtt" ) -// NewPublishStub returns a new stub for mqtt.Client Publish with a fixed return -// value. -func NewPublishStub(returnFix error) func(quit <-chan struct{}, message []byte, topic string) error { - return func(quit <-chan struct{}, message []byte, topic string) error { - select { - case <-quit: - return mqtt.ErrCanceled - default: - return returnFix - } - } -} - // Transfer defines a message exchange. type Transfer struct { Message []byte // payload @@ -95,6 +82,19 @@ func NewPublishMock(t testing.TB, want ...Transfer) func(quit <-chan struct{}, m } } +// NewPublishStub returns a new stub for mqtt.Client Publish with a fixed return +// value. +func NewPublishStub(returnFix error) func(quit <-chan struct{}, message []byte, topic string) error { + return func(quit <-chan struct{}, message []byte, topic string) error { + select { + case <-quit: + return mqtt.ErrCanceled + default: + return returnFix + } + } +} + // AckBlock prevents ack <-chan error submission. type AckBlock struct { Delay time.Duration // zero defaults to indefinite