Skip to content

Commit d07097b

Browse files
authored
fix(e2e): move deletion of sqs queues to After call (#3948)
1 parent 4f8b2a5 commit d07097b

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

features/sqs/messages.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ Feature: SQS Messages
1010
Then the result should include a message ID
1111
And the result should have an MD5 digest of "eb61eead90e3b899c6bcbe27ac581660"
1212
And I should eventually be able to receive "HELLO" from the queue
13-
Then I delete the SQS queue
1413

1514
Scenario: Binary payloads
1615
Given I create a queue with the prefix name "aws-js-sdk"
1716
When I send the message "HELLO" with a binary attribute
1817
Then the result should include a message ID
1918
And the result should have an MD5 digest of "eb61eead90e3b899c6bcbe27ac581660"
2019
And I should eventually be able to receive "HELLO" from the queue with a binary attribute
21-
Then I delete the SQS queue

features/sqs/queues.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ Feature: SQS Queues
88
Given I create a queue with the prefix name "aws-js-sdk"
99
And I create a queue with the prefix name "aws-js-sdk"
1010
Then list queues should eventually return the queue urls
11-
Then I delete the SQS queue
12-
Then I delete the SQS queue

features/sqs/step_definitions/queues.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const { Given, Then } = require("@cucumber/cucumber");
22

3-
Given("I create a queue with the prefix name {string}", function (prefix, callback) {
3+
Given("I create a queue with the prefix name {string}", async function (prefix) {
44
const name = this.uniqueName(prefix);
5-
this.request(null, "createQueue", { QueueName: name }, callback, function () {
6-
this.queueUrl = this.data.QueueUrl;
7-
this.createdQueues.push(this.queueUrl);
8-
});
5+
const response = await this.service.createQueue({ QueueName: name });
6+
this.queueUrl = response.QueueUrl;
7+
this.createdQueues.push(this.queueUrl);
98
});
109

1110
Then("list queues should eventually return the queue urls", function (callback) {
@@ -29,8 +28,3 @@ Then("list queues should eventually return the queue urls", function (callback)
2928
{ maxTime: 60 }
3029
);
3130
});
32-
33-
Then("I delete the SQS queue", function (callback) {
34-
const url = this.createdQueues.pop();
35-
this.request(null, "deleteQueue", { QueueUrl: url }, callback);
36-
});

features/sqs/step_definitions/sqs.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
const { Before } = require("@cucumber/cucumber");
1+
const { Before, After } = require("@cucumber/cucumber");
22

3-
Before({ tags: "@sqs" }, function (scenario, callback) {
3+
Before({ tags: "@sqs" }, function () {
44
const { SQS } = require("../../../clients/client-sqs");
5-
this.service = new SQS({
6-
region: "us-east-1",
7-
});
5+
this.service = new SQS({});
86
this.createdQueues = [];
9-
callback();
7+
});
8+
9+
After({ tags: "@sqs" }, async function () {
10+
for (const queueUrl of this.createdQueues) {
11+
await this.service.deleteQueue({ QueueUrl: queueUrl });
12+
}
1013
});

0 commit comments

Comments
 (0)