Skip to content

Commit 1096075

Browse files
committed
lint, 2
1 parent 8f5d013 commit 1096075

6 files changed

Lines changed: 22 additions & 29 deletions

File tree

config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import (
55
"fmt"
66
"time"
77

8+
"github.com/blokur/harego/v2/internal"
89
"github.com/bombsimon/logrusr/v4"
910
"github.com/go-logr/logr"
1011
amqp "github.com/rabbitmq/amqp091-go"
1112
"github.com/sirupsen/logrus"
12-
13-
"github.com/blokur/harego/v2/internal"
1413
)
1514

1615
// rabbitWrapper is defined to make it easy for passing a mocked connection.

consumer_integration_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import (
99
"testing"
1010
"time"
1111

12+
"github.com/blokur/harego/v2"
1213
"github.com/blokur/testament"
1314
"github.com/google/go-cmp/cmp"
1415
amqp "github.com/rabbitmq/amqp091-go"
1516
"github.com/stretchr/testify/assert"
1617
"github.com/stretchr/testify/require"
1718
"github.com/testcontainers/testcontainers-go"
18-
19-
"github.com/blokur/harego/v2"
2019
)
2120

2221
func TestIntegConsumer(t *testing.T) {
@@ -160,7 +159,7 @@ func testIntegConsumerConsumeNack(t *testing.T) {
160159
)
161160

162161
err = retryConfig.Do(func() error {
163-
_, addr = getContainer(t, t.Context())
162+
_, addr = getContainer(t.Context(), t)
164163
return nil
165164
}, func() error {
166165
cons1, err = harego.NewConsumer(harego.URLConnector(addr),
@@ -370,7 +369,7 @@ func testIntegConsumerSeparatedConsumePublish(t *testing.T) {
370369
var err error
371370

372371
err = retryConfig.Do(func() error {
373-
_, addr = getContainer(t, t.Context())
372+
_, addr = getContainer(t.Context(), t)
374373
return nil
375374
}, func() error {
376375
_, pub1, err = getConsumerPublisherWithAddr(t, addr, exchange1, "")
@@ -480,7 +479,7 @@ func testIntegConsumerUseSameQueue(t *testing.T) {
480479
)
481480

482481
err = retryConfig.Do(func() error {
483-
_, addr = getContainer(t, t.Context())
482+
_, addr = getContainer(t.Context(), t)
484483
return nil
485484
}, func() error {
486485
_, pub1, err = getConsumerPublisherWithAddr(t, addr, exchange1, queueName)
@@ -567,7 +566,7 @@ func testIntegConsumerPublishWorkers(t *testing.T) {
567566
)
568567

569568
err = retryConfig.Do(func() error {
570-
_, addr = getContainer(t, t.Context())
569+
_, addr = getContainer(t.Context(), t)
571570
return nil
572571
}, func() error {
573572
_, pub, err = getConsumerPublisherWithAddr(t, addr, exchange1, queueName,
@@ -651,7 +650,7 @@ func testIntegConsumerReconnect(t *testing.T) {
651650
)
652651

653652
err = retryConfig.Do(func() error {
654-
container, addr = getContainer(t, t.Context())
653+
container, addr = getContainer(t.Context(), t)
655654
return nil
656655
}, func() error {
657656
pub, err = harego.NewPublisher(harego.URLConnector(addr),
@@ -688,7 +687,7 @@ func testIntegConsumerReconnect(t *testing.T) {
688687

689688
go func() {
690689
<-restart
691-
restartRabbitMQ(t, t.Context(), container)
690+
restartRabbitMQ(t.Context(), t, container)
692691
}()
693692

694693
wGroup.Add(1)

consumer_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ import (
99
"testing"
1010
"time"
1111

12+
"github.com/blokur/harego/v2"
13+
"github.com/blokur/harego/v2/mocks"
14+
"github.com/blokur/testament"
1215
"github.com/google/go-cmp/cmp"
1316
amqp "github.com/rabbitmq/amqp091-go"
1417
"github.com/stretchr/testify/assert"
1518
"github.com/stretchr/testify/mock"
1619
"github.com/stretchr/testify/require"
17-
18-
"github.com/blokur/testament"
19-
20-
"github.com/blokur/harego/v2"
21-
"github.com/blokur/harego/v2/mocks"
2220
)
2321

2422
func TestNewConsumer(t *testing.T) {

helper_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"time"
1212

1313
"github.com/arsham/retry/v2"
14+
"github.com/blokur/harego/v2"
15+
"github.com/blokur/harego/v2/mocks"
1416
"github.com/blokur/testament"
1517
"github.com/containers/storage/pkg/ioutils"
1618
"github.com/docker/docker/api/types/container"
@@ -20,9 +22,6 @@ import (
2022
"github.com/stretchr/testify/require"
2123
"github.com/testcontainers/testcontainers-go"
2224
"github.com/testcontainers/testcontainers-go/modules/rabbitmq"
23-
24-
"github.com/blokur/harego/v2"
25-
"github.com/blokur/harego/v2/mocks"
2625
)
2726

2827
func randomBody(lines int) string {
@@ -68,7 +67,7 @@ func getConsumerPublisher(
6867
err := retryConfig.Do(func() error {
6968
var err error
7069

71-
ctner, addr = getContainer(t, ctx)
70+
ctner, addr = getContainer(ctx, t)
7271

7372
cons, pub, err = getConsumerPublisherWithAddr(t, addr, exchange, queueName, conf...)
7473
if err != nil {
@@ -152,7 +151,7 @@ func getConsumerPublisherWithAddr(
152151

153152
// getContainer returns a new container running rabbimq that is ready for
154153
// accepting connections.
155-
func getContainer(t *testing.T, parentCtx context.Context) (*rabbitmq.RabbitMQContainer, string) {
154+
func getContainer(parentCtx context.Context, t *testing.T) (*rabbitmq.RabbitMQContainer, string) {
156155
t.Helper()
157156

158157
ctx, cancel := context.WithTimeout(parentCtx, 600*time.Second)
@@ -187,7 +186,7 @@ func getContainer(t *testing.T, parentCtx context.Context) (*rabbitmq.RabbitMQCo
187186
}
188187

189188
// restartRabbitMQ restarts the rabbitmq server inside the container.
190-
func restartRabbitMQ(t *testing.T, parentCtx context.Context, ctner testcontainers.Container) {
189+
func restartRabbitMQ(parentCtx context.Context, t *testing.T, ctner testcontainers.Container) {
191190
t.Helper()
192191

193192
ctx, cancel := context.WithTimeout(parentCtx, time.Minute)

publisher_integration_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import (
99
"testing"
1010
"time"
1111

12+
"github.com/blokur/harego/v2"
1213
"github.com/blokur/testament"
1314
"github.com/google/go-cmp/cmp"
1415
amqp "github.com/rabbitmq/amqp091-go"
1516
"github.com/stretchr/testify/assert"
1617
"github.com/stretchr/testify/require"
1718
"github.com/testcontainers/testcontainers-go"
18-
19-
"github.com/blokur/harego/v2"
2019
)
2120

2221
func TestIntegPublisher(t *testing.T) {
@@ -108,7 +107,7 @@ func testIntegPublisherPublishWorkers(t *testing.T) {
108107
)
109108

110109
err = retryConfig.Do(func() error {
111-
_, addr = getContainer(t, t.Context())
110+
_, addr = getContainer(t.Context(), t)
112111
return nil
113112
}, func() error {
114113
_, pub, err = getConsumerPublisherWithAddr(t, addr, exchange1, queueName,
@@ -193,7 +192,7 @@ func testIntegPublisherReconnect(t *testing.T) {
193192
)
194193

195194
err = retryConfig.Do(func() error {
196-
container, addr = getContainer(t, t.Context())
195+
container, addr = getContainer(t.Context(), t)
197196
return nil
198197
}, func() error {
199198
cons, pub, err = getConsumerPublisherWithAddr(t, addr, exchange, queueName, harego.RetryDelay(time.Second/2))
@@ -215,7 +214,7 @@ func testIntegPublisherReconnect(t *testing.T) {
215214
for {
216215
select {
217216
case ch := <-restart:
218-
restartRabbitMQ(t, ctx, container)
217+
restartRabbitMQ(ctx, t, container)
219218
close(ch)
220219
case <-ctx.Done():
221220
return

publisher_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/blokur/harego/v2"
11+
"github.com/blokur/harego/v2/mocks"
1012
"github.com/blokur/testament"
1113
amqp "github.com/rabbitmq/amqp091-go"
1214
"github.com/stretchr/testify/assert"
1315
"github.com/stretchr/testify/mock"
1416
"github.com/stretchr/testify/require"
15-
16-
"github.com/blokur/harego/v2"
17-
"github.com/blokur/harego/v2/mocks"
1817
)
1918

2019
func TestNewPublisher(t *testing.T) {

0 commit comments

Comments
 (0)