Skip to content

Commit d8e6a9a

Browse files
authored
fix(e2e): delete cognitoidentity resources in After call (#3955)
1 parent b30b9b2 commit d8e6a9a

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

features/cognitoidentity/cognitoidentity.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Feature:
88
Given I create a Cognito identity pool with prefix "awssdkjs"
99
And I describe the Cognito identity pool ID
1010
Then the status code should be 200
11-
And I delete the Cognito identity pool
1211

1312
Scenario: Error handling
1413
Given I create a Cognito identity pool with prefix ""
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
const { Before, Given, Then } = require("@cucumber/cucumber");
1+
const { After, Before, Given } = require("@cucumber/cucumber");
22

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

9-
Given("I create a Cognito identity pool with prefix {string}", function (prefix, callback) {
10-
const expectError = prefix === "" ? false : undefined;
11-
const params = {
12-
IdentityPoolName: this.uniqueName(prefix, ""),
13-
AllowUnauthenticatedIdentities: true,
14-
};
15-
this.request(null, "createIdentityPool", params, callback, expectError);
8+
After({ tags: "@cognitoidentity" }, async function () {
9+
if (this.identityPoolId) {
10+
this.service.deleteIdentityPool({ IdentityPoolId: this.identityPoolId });
11+
this.identityPoolId = undefined;
12+
}
1613
});
1714

18-
Given("I describe the Cognito identity pool ID", function (callback) {
19-
this.identityPoolId = this.data.IdentityPoolId;
20-
this.request(null, "describeIdentityPool", { IdentityPoolId: this.data.IdentityPoolId }, callback);
15+
Given("I create a Cognito identity pool with prefix {string}", async function (prefix) {
16+
try {
17+
this.data = await this.service.createIdentityPool({
18+
IdentityPoolName: this.uniqueName(prefix),
19+
AllowUnauthenticatedIdentities: true,
20+
});
21+
this.identityPoolId = this.data.IdentityPoolId;
22+
} catch (error) {
23+
this.error = error;
24+
}
2125
});
2226

23-
Then("I delete the Cognito identity pool", function (callback) {
24-
this.request(null, "deleteIdentityPool", { IdentityPoolId: this.identityPoolId }, callback);
27+
Given("I describe the Cognito identity pool ID", async function () {
28+
this.data = await this.service.describeIdentityPool({ IdentityPoolId: this.identityPoolId });
2529
});

0 commit comments

Comments
 (0)