Skip to content

Commit 41216e7

Browse files
committed
fix(e2e): delete eleasticache resources in After call
1 parent 8ed83f0 commit 41216e7

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

features/elasticache/elasticache.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Feature: Amazon ElastiCache
1010
And I describe the cache parameter groups
1111
Then the value at "CacheParameterGroups" should be a list
1212
And the cache parameter group should be described
13-
And I delete the cache parameter group
1413

1514
Scenario: Error handling
1615
Given I create a cache parameter group with name prefix ""
Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1-
const { Before, Given, Then } = require("@cucumber/cucumber");
1+
const { After, Before, Given, Then } = require("@cucumber/cucumber");
22

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

9-
Given("I create a cache parameter group with name prefix {string}", function (prefix, callback) {
8+
After({ tags: "@elasticache" }, async function () {
9+
if (this.cacheGroupName) {
10+
await this.service.deleteCacheParameterGroup({ CacheParameterGroupName: this.cacheGroupName });
11+
this.cacheGroupName = undefined;
12+
}
13+
});
14+
15+
Given("I create a cache parameter group with name prefix {string}", async function (prefix) {
1016
this.cacheGroupName = this.uniqueName(prefix);
1117
const params = {
1218
Description: "Description",
1319
CacheParameterGroupName: this.cacheGroupName,
1420
CacheParameterGroupFamily: "memcached1.4",
1521
};
16-
this.request(null, "createCacheParameterGroup", params, callback, false);
22+
try {
23+
this.data = await this.service.createCacheParameterGroup(params);
24+
} catch (error) {
25+
this.error = error;
26+
}
1727
});
1828

19-
Given("the cache parameter group name is in the result", function (callback) {
29+
Given("the cache parameter group name is in the result", async function () {
2030
const name = this.data.CacheParameterGroup.CacheParameterGroupName;
2131
this.assert.equal(name, this.cacheGroupName);
22-
callback();
2332
});
2433

25-
Given("I describe the cache parameter groups", function (callback) {
34+
Given("I describe the cache parameter groups", async function () {
2635
const params = {
2736
CacheParameterGroupName: this.cacheGroupName,
2837
};
29-
this.request(null, "describeCacheParameterGroups", params, callback);
38+
try {
39+
this.data = await this.service.describeCacheParameterGroups(params);
40+
} catch (error) {
41+
this.error = error;
42+
}
3043
});
3144

32-
Then("the cache parameter group should be described", function (callback) {
45+
Then("the cache parameter group should be described", function () {
3346
const item = this.data.CacheParameterGroups[0];
3447
this.assert.equal(item.CacheParameterGroupName, this.cacheGroupName);
35-
callback();
36-
});
37-
38-
Then("I delete the cache parameter group", function (callback) {
39-
const params = {
40-
CacheParameterGroupName: this.cacheGroupName,
41-
};
42-
this.request(null, "deleteCacheParameterGroup", params, callback);
4348
});

0 commit comments

Comments
 (0)