Skip to content

Commit 8efcc12

Browse files
authored
fix(e2e): delete elasticbeanstalk app in After call (#3958)
1 parent 9195a8c commit 8efcc12

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

features/elasticbeanstalk/elasticbeanstalk.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Feature: AWS Elastic Beanstalk
1111
And I describe the Elastic Beanstalk application
1212
Then the result should contain the Elastic Beanstalk application version
1313
And the result should contain the Elastic Beanstalk application name
14-
And I delete the Elastic Beanstalk application
1514

1615
Scenario: Error handling
1716
Given I create an Elastic Beanstalk application with name prefix ""
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
const { Before, Given, Then } = require("@cucumber/cucumber");
1+
const { After, Before, Given, Then } = require("@cucumber/cucumber");
22

3-
Before({ tags: "@elasticbeanstalk" }, function (scenario, callback) {
3+
Before({ tags: "@elasticbeanstalk" }, function () {
44
const { ElasticBeanstalk } = require("../../../clients/client-elastic-beanstalk");
55
this.service = new ElasticBeanstalk({});
6-
callback();
76
});
87

9-
Given("I create an Elastic Beanstalk application with name prefix {string}", function (prefix, callback) {
8+
After({ tags: "@elasticbeanstalk" }, async function () {
9+
if (this.appName) {
10+
await this.service.deleteApplication({ ApplicationName: this.appName });
11+
this.appName = undefined;
12+
}
13+
});
14+
15+
Given("I create an Elastic Beanstalk application with name prefix {string}", async function (prefix) {
1016
this.appName = this.uniqueName(prefix);
11-
const params = { ApplicationName: this.appName };
12-
this.request(null, "createApplication", params, callback, false);
17+
try {
18+
this.data = await this.service.createApplication({ ApplicationName: this.appName });
19+
} catch (error) {
20+
this.error = error;
21+
}
1322
});
1423

15-
Given("I create an Elastic Beanstalk application version with label {string}", function (label, callback) {
24+
Given("I create an Elastic Beanstalk application version with label {string}", async function (label) {
1625
this.appVersion = label;
1726
const params = {
1827
ApplicationName: this.appName,
1928
VersionLabel: this.appVersion,
2029
};
21-
this.request(null, "createApplicationVersion", params, callback);
30+
await this.service.createApplicationVersion(params);
2231
});
2332

24-
Given("I describe the Elastic Beanstalk application", function (callback) {
33+
Given("I describe the Elastic Beanstalk application", async function () {
2534
const params = { ApplicationNames: [this.appName] };
26-
this.request(null, "describeApplications", params, callback);
35+
this.data = await this.service.describeApplications(params);
2736
});
2837

29-
Then("the result should contain the Elastic Beanstalk application version", function (callback) {
38+
Then("the result should contain the Elastic Beanstalk application version", function () {
3039
this.assert.deepEqual(this.data.Applications[0].Versions, [this.appVersion]);
31-
callback();
3240
});
3341

34-
Then("the result should contain the Elastic Beanstalk application name", function (callback) {
42+
Then("the result should contain the Elastic Beanstalk application name", function () {
3543
this.assert.equal(this.data.Applications[0].ApplicationName, this.appName);
36-
callback();
37-
});
38-
39-
Then("I delete the Elastic Beanstalk application", function (callback) {
40-
const params = { ApplicationName: this.appName };
41-
this.request(null, "deleteApplication", params, callback);
4244
});

0 commit comments

Comments
 (0)