1
0
mirror of https://github.com/go-mqtt/mqtt.git synced 2025-08-07 11:42:52 +03:00

Nonfunctional code reorder.

This commit is contained in:
Pascal S. de Kloe
2021-02-18 23:07:27 +01:00
parent d5046be0f5
commit c1e51592da

View File

@@ -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