Skip to content

Commit

Permalink
fix: clean s3 buckets after integration test is run (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Apr 2, 2020
1 parent 272d1e0 commit 3cbdb37
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions features/extra/cleanup.js
@@ -1,3 +1,5 @@
var { S3 } = require("../../clients/client-s3");

module.exports = function() {
/**
* Cleanup fixtures and resources. The world does not exist when
Expand Down Expand Up @@ -71,7 +73,7 @@ module.exports = function() {
* Delete bucket
*/
var deleteBucket = function(bucket, callback) {
var s3 = new AWS.S3({ maxRetries: 100 });
var s3 = new S3({ maxRetries: 100 });
s3.deleteBucket({ Bucket: bucket }, function(err, data) {
callback(err);
});
Expand All @@ -81,14 +83,14 @@ module.exports = function() {
* Delete objects.
*/
var deleteObjects = function(bucket, callback) {
var s3 = new AWS.S3({ maxRetries: 100 });
var s3 = new S3({ maxRetries: 100 });
var params = {
Bucket: bucket
};

s3.listObjects(params, function(err, data) {
if (err) return callback(err);
if (data.Contents.length > 0) {
if (data.Contents && data.Contents.length > 0) {
params.Delete = { Objects: [] };
data.Contents.forEach(function(item) {
params.Delete.Objects.push({ Key: item.Key });
Expand Down

0 comments on commit 3cbdb37

Please sign in to comment.