@@ -6,15 +6,15 @@ import (
66 "testing"
77 "time"
88
9- "github.com/smartcontractkit/chainlink-common/pkg/chipingress"
10- "github.com/smartcontractkit/chainlink-common/pkg/chipingress/mocks"
119 "github.com/stretchr/testify/assert"
1210 "github.com/stretchr/testify/mock"
1311 "github.com/stretchr/testify/require"
12+
13+ "github.com/smartcontractkit/chainlink-common/pkg/chipingress"
14+ "github.com/smartcontractkit/chainlink-common/pkg/chipingress/mocks"
1415)
1516
1617func TestNewBatchClient (t * testing.T ) {
17-
1818 t .Run ("NewBatchClient" , func (t * testing.T ) {
1919 client , err := NewBatchClient (nil )
2020 require .NoError (t , err )
@@ -53,9 +53,7 @@ func TestNewBatchClient(t *testing.T) {
5353}
5454
5555func TestQueueMessage (t * testing.T ) {
56-
5756 t .Run ("successfully queues a message" , func (t * testing.T ) {
58-
5957 client , err := NewBatchClient (nil , WithMessageBuffer (5 ))
6058 require .NoError (t , err )
6159
@@ -67,7 +65,7 @@ func TestQueueMessage(t *testing.T) {
6765
6866 client .QueueMessage (event )
6967
70- assert .Equal (t , 1 , len ( client .messageBuffer ) )
68+ assert .Len (t , client .messageBuffer , 1 )
7169
7270 received := <- client .messageBuffer
7371 assert .Equal (t , event .Id , received .Id )
@@ -76,7 +74,6 @@ func TestQueueMessage(t *testing.T) {
7674 })
7775
7876 t .Run ("drops message if buffer is full" , func (t * testing.T ) {
79-
8077 client , err := NewBatchClient (nil , WithMessageBuffer (1 ))
8178 require .NoError (t , err )
8279 require .NotNil (t , client )
@@ -90,7 +87,7 @@ func TestQueueMessage(t *testing.T) {
9087 client .QueueMessage (event )
9188 client .QueueMessage (event )
9289
93- assert .Equal (t , 1 , len ( client .messageBuffer ) )
90+ assert .Len (t , client .messageBuffer , 1 )
9491
9592 received := <- client .messageBuffer
9693 assert .Equal (t , event .Id , received .Id )
@@ -103,14 +100,12 @@ func TestQueueMessage(t *testing.T) {
103100 require .NoError (t , err )
104101
105102 client .QueueMessage (nil )
106- assert .Equal (t , 0 , len ( client .messageBuffer ) )
103+ assert .Empty (t , client .messageBuffer )
107104 })
108105}
109106
110107func TestSendBatch (t * testing.T ) {
111-
112108 t .Run ("successfully sends a batch" , func (t * testing.T ) {
113-
114109 mockClient := mocks .NewClient (t )
115110 done := make (chan struct {})
116111
@@ -150,7 +145,6 @@ func TestSendBatch(t *testing.T) {
150145 })
151146
152147 t .Run ("doesn't publish empty batch" , func (t * testing.T ) {
153-
154148 mockClient := mocks .NewClient (t )
155149
156150 client , err := NewBatchClient (mockClient , WithMessageBuffer (5 ))
@@ -208,7 +202,6 @@ func TestSendBatch(t *testing.T) {
208202}
209203
210204func TestStart (t * testing.T ) {
211-
212205 t .Run ("batch size trigger" , func (t * testing.T ) {
213206 mockClient := mocks .NewClient (t )
214207 done := make (chan struct {})
@@ -366,7 +359,6 @@ func TestStart(t *testing.T) {
366359 })
367360
368361 t .Run ("no flush when batch is empty" , func (t * testing.T ) {
369-
370362 mockClient := mocks .NewClient (t )
371363
372364 client , err := NewBatchClient (mockClient , WithBatchSize (10 ), WithBatchTimeout (5 * time .Second ))
@@ -385,7 +377,6 @@ func TestStart(t *testing.T) {
385377 })
386378
387379 t .Run ("multiple batches via size trigger" , func (t * testing.T ) {
388-
389380 mockClient := mocks .NewClient (t )
390381 done := make (chan struct {})
391382 callCount := 0
0 commit comments