@@ -35,6 +35,7 @@ import (
35
35
mocks_sqs "github.com/nitrictech/nitric/cloud/aws/mocks/sqs"
36
36
"github.com/nitrictech/nitric/cloud/aws/runtime/resource"
37
37
queuepb "github.com/nitrictech/nitric/core/pkg/proto/queues/v1"
38
+ queuespb "github.com/nitrictech/nitric/core/pkg/proto/queues/v1"
38
39
)
39
40
40
41
var _ = Describe ("Sqs" , func () {
@@ -114,13 +115,15 @@ var _ = Describe("Sqs", func() {
114
115
By ("Calling SendMessageBatch with the expected batch entries" )
115
116
sqsMock .EXPECT ().SendMessageBatch (gomock .Any (), gomock .Any ()).Return (& sqs.SendMessageBatchOutput {}, nil )
116
117
117
- _ , err := plugin .Send (context .TODO (), & queuepb.QueueSendRequestBatch {
118
+ _ , err := plugin .Enqueue (context .TODO (), & queuepb.QueueEnqueueRequest {
118
119
QueueName : "test-queue" ,
119
- Requests : []* queuepb. QueueSendRequest {
120
+ Messages : []* queuespb. QueueMessage {
120
121
{
121
- Payload : & structpb.Struct {
122
- Fields : map [string ]* structpb.Value {
123
- "Test" : structpb .NewStringValue ("Test" ),
122
+ Content : & queuespb.QueueMessage_StructPayload {
123
+ StructPayload : & structpb.Struct {
124
+ Fields : map [string ]* structpb.Value {
125
+ "Test" : structpb .NewStringValue ("Test" ),
126
+ },
124
127
},
125
128
},
126
129
},
@@ -162,13 +165,15 @@ var _ = Describe("Sqs", func() {
162
165
By ("Calling SendMessageBatch with the expected batch entries" )
163
166
sqsMock .EXPECT ().SendMessageBatch (gomock .Any (), gomock .Any ()).Return (nil , opErr )
164
167
165
- _ , err := plugin .Send (context .TODO (), & queuepb.QueueSendRequestBatch {
168
+ _ , err := plugin .Enqueue (context .TODO (), & queuepb.QueueEnqueueRequest {
166
169
QueueName : "test-queue" ,
167
- Requests : []* queuepb.QueueSendRequest {
170
+ Messages : []* queuepb.QueueMessage {
168
171
{
169
- Payload : & structpb.Struct {
170
- Fields : map [string ]* structpb.Value {
171
- "Test" : structpb .NewStringValue ("Test" ),
172
+ Content : & queuepb.QueueMessage_StructPayload {
173
+ StructPayload : & structpb.Struct {
174
+ Fields : map [string ]* structpb.Value {
175
+ "Test" : structpb .NewStringValue ("Test" ),
176
+ },
172
177
},
173
178
},
174
179
},
@@ -193,13 +198,15 @@ var _ = Describe("Sqs", func() {
193
198
By ("provider GetResources returning an error" )
194
199
providerMock .EXPECT ().GetResources (gomock .Any (), resource .AwsResource_Queue ).Return (nil , fmt .Errorf ("mock-error" ))
195
200
196
- _ , err := plugin .Send (context .TODO (), & queuepb.QueueSendRequestBatch {
201
+ _ , err := plugin .Enqueue (context .TODO (), & queuepb.QueueEnqueueRequest {
197
202
QueueName : "test-queue" ,
198
- Requests : []* queuepb.QueueSendRequest {
203
+ Messages : []* queuepb.QueueMessage {
199
204
{
200
- Payload : & structpb.Struct {
201
- Fields : map [string ]* structpb.Value {
202
- "Test" : structpb .NewStringValue ("Test" ),
205
+ Content : & queuepb.QueueMessage_StructPayload {
206
+ StructPayload : & structpb.Struct {
207
+ Fields : map [string ]* structpb.Value {
208
+ "Test" : structpb .NewStringValue ("Test" ),
209
+ },
203
210
},
204
211
},
205
212
},
@@ -256,15 +263,15 @@ var _ = Describe("Sqs", func() {
256
263
}, nil )
257
264
258
265
By ("Returning the task" )
259
- response , err := plugin .Receive (context .TODO (), & queuepb.QueueReceiveRequest {
266
+ response , err := plugin .Dequeue (context .TODO (), & queuepb.QueueDequeueRequest {
260
267
QueueName : "mock-queue" ,
261
268
Depth : 10 ,
262
269
})
263
270
264
271
Expect (err ).ShouldNot (HaveOccurred ())
265
- Expect (response .Tasks ).To (HaveLen (1 ))
266
- Expect (response .Tasks [0 ].LeaseId ).To (BeEquivalentTo ("mockreceipthandle" ))
267
- Expect (response .Tasks [0 ].Payload .AsMap ()).To (BeEquivalentTo (testStruct .AsMap ()))
272
+ Expect (response .Messages ).To (HaveLen (1 ))
273
+ Expect (response .Messages [0 ].LeaseId ).To (BeEquivalentTo ("mockreceipthandle" ))
274
+ Expect (response .Messages [0 ].Message . GetStructPayload () .AsMap ()).To (BeEquivalentTo (testStruct .AsMap ()))
268
275
269
276
ctrl .Finish ()
270
277
})
@@ -302,13 +309,13 @@ var _ = Describe("Sqs", func() {
302
309
Messages : []types.Message {},
303
310
}, nil )
304
311
305
- response , err := plugin .Receive (context .TODO (), & queuepb.QueueReceiveRequest {
312
+ response , err := plugin .Dequeue (context .TODO (), & queuepb.QueueDequeueRequest {
306
313
QueueName : "mock-queue" ,
307
314
Depth : 10 ,
308
315
})
309
316
310
317
By ("Returning an empty array of tasks" )
311
- Expect (response .Tasks ).To (HaveLen (0 ))
318
+ Expect (response .Messages ).To (HaveLen (0 ))
312
319
313
320
By ("Not returning an error" )
314
321
Expect (err ).ShouldNot (HaveOccurred ())
@@ -352,7 +359,7 @@ var _ = Describe("Sqs", func() {
352
359
QueueUrl : queueUrl ,
353
360
}).Times (1 ).Return (nil , opErr )
354
361
355
- _ , err := plugin .Receive (context .TODO (), & queuepb.QueueReceiveRequest {
362
+ _ , err := plugin .Dequeue (context .TODO (), & queuepb.QueueDequeueRequest {
356
363
QueueName : "mock-queue" ,
357
364
Depth : 10 ,
358
365
})
0 commit comments