Skip to content

Commit 8b85e8e

Browse files
committed
fixup
1 parent 0002649 commit 8b85e8e

1 file changed

Lines changed: 84 additions & 35 deletions

File tree

tests/functional/metadata/MixedVersionFormat.js

Lines changed: 84 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
const assert = require('assert');
22
const async = require('async');
3+
const {
4+
PutObjectCommand,
5+
GetObjectCommand,
6+
ListObjectsCommand,
7+
PutBucketVersioningCommand,
8+
ListObjectVersionsCommand
9+
} = require('@aws-sdk/client-s3');
310
const withV4 = require('../aws-node-sdk/test/support/withV4');
411
const BucketUtility = require('../aws-node-sdk/lib/utility/bucket-util');
512
const MongoClient = require('mongodb').MongoClient;
@@ -113,25 +120,40 @@ describe('Mongo backend mixed bucket format versions', () => {
113120
};
114121
const masterKey = vFormat === 'v0' ? `${vFormat}-object-1` : `\x7fM${vFormat}-object-1`;
115122
async.series([
116-
next => s3.putObject(paramsObj1, next),
117-
next => s3.putObject(paramsObj2, next),
123+
next => {
124+
s3.send(new PutObjectCommand(paramsObj1))
125+
.then(() => next())
126+
.catch(next);
127+
},
128+
next => {
129+
s3.send(new PutObjectCommand(paramsObj2))
130+
.then(() => next())
131+
.catch(next);
132+
},
118133
// check if data stored in the correct format
119134
next => getObject(`${vFormat}-bucket`, masterKey, (err, doc) => {
120135
assert.ifError(err);
121136
assert.strictEqual(doc.key, `${vFormat}-object-1`);
122137
return next();
123138
}),
124139
// test if we can get object
125-
next => s3.getObject(paramsObj1, next),
140+
next => {
141+
s3.send(new GetObjectCommand(paramsObj1))
142+
.then(() => next())
143+
.catch(next);
144+
},
126145
// test if we can list objects
127-
next => s3.listObjects({ Bucket: `${vFormat}-bucket` }, (err, data) => {
128-
assert.ifError(err);
129-
assert.strictEqual(data.Contents.length, 2);
130-
const keys = data.Contents.map(obj => obj.Key);
131-
assert(keys.includes(`${vFormat}-object-1`));
132-
assert(keys.includes(`${vFormat}-object-2`));
133-
return next();
134-
})
146+
next => {
147+
s3.send(new ListObjectsCommand({ Bucket: `${vFormat}-bucket` }))
148+
.then(data => {
149+
assert.strictEqual(data.Contents.length, 2);
150+
const keys = data.Contents.map(obj => obj.Key);
151+
assert(keys.includes(`${vFormat}-object-1`));
152+
assert(keys.includes(`${vFormat}-object-2`));
153+
next();
154+
})
155+
.catch(next);
156+
}
135157
], done);
136158
});
137159

@@ -151,40 +173,67 @@ describe('Mongo backend mixed bucket format versions', () => {
151173
}
152174
};
153175
const masterKey = vFormat === 'v0' ? `${vFormat}-object-1` : `\x7fM${vFormat}-object-1`;
176+
154177
async.series([
155-
next => s3.putBucketVersioning(versioningParams, next),
156-
next => s3.putObject(paramsObj1, next),
157-
next => s3.putObject(paramsObj1, next),
158-
next => s3.putObject(paramsObj2, next),
178+
next => {
179+
s3.send(new PutBucketVersioningCommand(versioningParams))
180+
.then(() => next())
181+
.catch(next);
182+
},
183+
next => {
184+
s3.send(new PutObjectCommand(paramsObj1))
185+
.then(() => next())
186+
.catch(next);
187+
},
188+
next => {
189+
s3.send(new PutObjectCommand(paramsObj1))
190+
.then(() => next())
191+
.catch(next);
192+
},
193+
next => {
194+
s3.send(new PutObjectCommand(paramsObj2))
195+
.then(() => next())
196+
.catch(next);
197+
},
159198
// check if data stored in the correct version format
160199
next => getObject(`${vFormat}-bucket`, masterKey, (err, doc) => {
161200
assert.ifError(err);
162201
assert.strictEqual(doc.key, `${vFormat}-object-1`);
163202
return next();
164203
}),
165204
// test if we can get object
166-
next => s3.getObject(paramsObj1, next),
205+
next => {
206+
s3.send(new GetObjectCommand(paramsObj1))
207+
.then(() => next())
208+
.catch(next);
209+
},
167210
// test if we can list objects
168-
next => s3.listObjects({ Bucket: `${vFormat}-bucket` }, (err, data) => {
169-
assert.ifError(err);
170-
assert.strictEqual(data.Contents.length, 2);
171-
const keys = data.Contents.map(obj => obj.Key);
172-
assert(keys.includes(`${vFormat}-object-1`));
173-
assert(keys.includes(`${vFormat}-object-2`));
174-
return next();
175-
}),
211+
next => {
212+
s3.send(new ListObjectsCommand({ Bucket: `${vFormat}-bucket` }))
213+
.then(data => {
214+
assert.strictEqual(data.Contents.length, 2);
215+
const keys = data.Contents.map(obj => obj.Key);
216+
assert(keys.includes(`${vFormat}-object-1`));
217+
assert(keys.includes(`${vFormat}-object-2`));
218+
next();
219+
})
220+
.catch(next);
221+
},
176222
// test if we can list object versions
177-
next => s3.listObjectVersions({ Bucket: `${vFormat}-bucket` }, (err, data) => {
178-
assert.ifError(err);
179-
assert.strictEqual(data.Versions.length, 3);
180-
const versionPerObject = {};
181-
data.Versions.forEach(version => {
182-
versionPerObject[version.Key] = (versionPerObject[version.Key] || 0) + 1;
183-
});
184-
assert.strictEqual(versionPerObject[`${vFormat}-object-1`], 2);
185-
assert.strictEqual(versionPerObject[`${vFormat}-object-2`], 1);
186-
return next();
187-
})
223+
next => {
224+
s3.send(new ListObjectVersionsCommand({ Bucket: `${vFormat}-bucket` }))
225+
.then(data => {
226+
assert.strictEqual(data.Versions.length, 3);
227+
const versionPerObject = {};
228+
data.Versions.forEach(version => {
229+
versionPerObject[version.Key] = (versionPerObject[version.Key] || 0) + 1;
230+
});
231+
assert.strictEqual(versionPerObject[`${vFormat}-object-1`], 2);
232+
assert.strictEqual(versionPerObject[`${vFormat}-object-2`], 1);
233+
next();
234+
})
235+
.catch(next);
236+
}
188237
], done);
189238
});
190239
});

0 commit comments

Comments
 (0)