Skip to content

Commit

Permalink
respond to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
garbados committed Dec 1, 2021
1 parent 0e90f59 commit 78315fd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 39 deletions.
7 changes: 2 additions & 5 deletions merged/aws-sdk/lib/v3-sqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ function sqsMiddleware(shim, next, context) {
* @returns {Object}
*/
function getSqsSpec(shim, original, name, args) {
const [
{
input: { QueueUrl }
}
] = args
const [command] = args
const { QueueUrl } = command.input
return {
callback: shim.LAST,
destinationName: grabLastUrlSegment(QueueUrl),
Expand Down
60 changes: 26 additions & 34 deletions merged/aws-sdk/tests/versioned/aws-sdk-v3/sqs.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

// TODO restore attribute checking, see checkAttributes

'use strict'

const tap = require('tap')
Expand Down Expand Up @@ -77,36 +75,32 @@ tap.test('SQS API', (t) => {
})

t.test('commands with promises', async (t) => {
try {
// create queue
const createParams = getCreateParams(queueName)
const createCommand = new CreateQueueCommand(createParams)
const { QueueUrl } = await sqs.send(createCommand)
t.ok(QueueUrl)
// run send/receive commands in transaction
await helper.runInTransaction(async (transaction) => {
// send message
const sendMessageParams = getSendMessageParams(QueueUrl)
const sendMessageCommand = new SendMessageCommand(sendMessageParams)
const { MessageId } = await sqs.send(sendMessageCommand)
t.ok(MessageId)
// send message batch
const sendMessageBatchParams = getSendMessageBatchParams(QueueUrl)
const sendMessageBatchCommand = new SendMessageBatchCommand(sendMessageBatchParams)
const { Successful } = await sqs.send(sendMessageBatchCommand)
t.ok(Successful)
// receive message
const receiveMessageParams = getReceiveMessageParams(QueueUrl)
const receiveMessageCommand = new ReceiveMessageCommand(receiveMessageParams)
const { Messages } = await sqs.send(receiveMessageCommand)
t.ok(Messages)
// wrap up
transaction.end()
await finish(t, transaction)
})
} catch (err) {
t.error(err)
}
// create queue
const createParams = getCreateParams(queueName)
const createCommand = new CreateQueueCommand(createParams)
const { QueueUrl } = await sqs.send(createCommand)
t.ok(QueueUrl)
// run send/receive commands in transaction
await helper.runInTransaction(async (transaction) => {
// send message
const sendMessageParams = getSendMessageParams(QueueUrl)
const sendMessageCommand = new SendMessageCommand(sendMessageParams)
const { MessageId } = await sqs.send(sendMessageCommand)
t.ok(MessageId)
// send message batch
const sendMessageBatchParams = getSendMessageBatchParams(QueueUrl)
const sendMessageBatchCommand = new SendMessageBatchCommand(sendMessageBatchParams)
const { Successful } = await sqs.send(sendMessageBatchCommand)
t.ok(Successful)
// receive message
const receiveMessageParams = getReceiveMessageParams(QueueUrl)
const receiveMessageCommand = new ReceiveMessageCommand(receiveMessageParams)
const { Messages } = await sqs.send(receiveMessageCommand)
t.ok(Messages)
// wrap up
transaction.end()
await finish(t, transaction)
})
})

function finish(t, transaction) {
Expand Down Expand Up @@ -134,8 +128,6 @@ tap.test('SQS API', (t) => {

checkName(t, receiveMessage.name, 'Consume', queueName)
checkAttributes(t, receiveMessage, 'ReceiveMessageCommand')

t.end()
}
})

Expand Down

0 comments on commit 78315fd

Please sign in to comment.