Skip to content

Commit 074ce64

Browse files
committed
multiple backend related tests migration
Issue: CLDSRV-724
1 parent f7874f9 commit 074ce64

File tree

4 files changed

+251
-210
lines changed

4 files changed

+251
-210
lines changed
Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
const assert = require('assert');
2+
const {
3+
CreateBucketCommand,
4+
GetBucketLocationCommand,
5+
PutObjectCommand,
6+
HeadObjectCommand,
7+
GetObjectCommand,
8+
} = require('@aws-sdk/client-s3');
29
const withV4 = require('../support/withV4');
310
const BucketUtility = require('../../lib/utility/bucket-util');
411
const config = require('../../../config.json');
@@ -21,27 +28,18 @@ describe('Requests to ip endpoint not in config', () => {
2128
s3 = bucketUtil.s3;
2229
});
2330

24-
after(() => {
31+
after(async () => {
2532
process.stdout.write('Emptying bucket\n');
26-
return bucketUtil.empty(bucket)
27-
.then(() => {
28-
process.stdout.write('Deleting bucket\n');
29-
return bucketUtil.deleteOne(bucket);
30-
})
31-
.catch(err => {
32-
process.stdout.write(`Error in afterEach: ${err}\n`);
33-
throw err;
34-
});
33+
await bucketUtil.empty(bucket);
34+
process.stdout.write('Deleting bucket\n');
35+
await bucketUtil.deleteOne(bucket);
3536
});
3637

3738
it('should accept put bucket request ' +
3839
'to IP address endpoint that is not in config using ' +
3940
'path style',
40-
done => {
41-
s3.createBucket({ Bucket: bucket }, err => {
42-
assert.ifError(err);
43-
done();
44-
});
41+
async () => {
42+
await s3.send(new CreateBucketCommand({ Bucket: bucket }));
4543
});
4644

4745
const itSkipIfE2E = process.env.S3_END_TO_END ? it.skip : it;
@@ -51,42 +49,25 @@ describe('Requests to ip endpoint not in config', () => {
5149
itSkipIfE2E('should show us-east-1 as bucket location since' +
5250
'IP address endpoint was not in config thereby ' +
5351
'defaulting to us-east-1',
54-
done => {
55-
s3.getBucketLocation({ Bucket: bucket },
56-
(err, res) => {
57-
assert.ifError(err);
58-
// us-east-1 is returned as empty string
59-
assert.strictEqual(res
60-
.LocationConstraint, '');
61-
done();
62-
});
52+
async () => {
53+
const res = await s3.send(new GetBucketLocationCommand({ Bucket: bucket }));
54+
assert.strictEqual(res.LocationConstraint, '');
6355
});
6456

6557
it('should accept put object request ' +
6658
'to IP address endpoint that is not in config using ' +
6759
'path style and use the bucket location for the object',
68-
done => {
69-
s3.putObject({ Bucket: bucket, Key: key, Body: body },
70-
err => {
71-
assert.ifError(err);
72-
return s3.headObject({ Bucket: bucket, Key: key },
73-
err => {
74-
assert.ifError(err);
75-
done();
76-
});
77-
});
60+
async () => {
61+
await s3.send(new PutObjectCommand({ Bucket: bucket, Key: key, Body: body }));
62+
await s3.send(new HeadObjectCommand({ Bucket: bucket, Key: key }));
7863
});
7964

8065
it('should accept get object request ' +
8166
'to IP address endpoint that is not in config using ' +
8267
'path style',
83-
done => {
84-
s3.getObject({ Bucket: bucket, Key: key },
85-
(err, res) => {
86-
assert.ifError(err);
87-
assert.strictEqual(res.ETag, expectedETag);
88-
done();
89-
});
68+
async () => {
69+
const res = await s3.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
70+
assert.strictEqual(res.ETag, expectedETag);
9071
});
9172
});
9273
});

0 commit comments

Comments
 (0)