Skip to content

Commit 3b05ec9

Browse files
CLDSRV-720: Fix test HEAD and partNumber (of MPU)
cf: CLDSRV-638
1 parent af09285 commit 3b05ec9

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

tests/functional/aws-node-sdk/test/object/getPartSize.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const object = 'mpu-test-object';
1010
const emptyObject = 'empty-object';
1111
const nonMpuObject = 'simple-object';
1212

13+
/** 5MiB */
1314
const bodySize = 1024 * 1024 * 5;
1415
const bodyContent = 'a';
1516
const howManyParts = 3;
@@ -18,6 +19,13 @@ const invalidPartNumbers = [-1, 0, maximumAllowedPartCount + 1];
1819

1920
let ETags = [];
2021

22+
// Because HEAD has no body, the SDK (v2) returns a generic code such as:
23+
// 400 BadRequest
24+
// 403 Forbidden
25+
// 404 NotFound
26+
// ...
27+
// It will fall back to HTTP statusCode
28+
// Example: 416 InvalidRange will be 416 416
2129
function checkError(err, statusCode, code) {
2230
assert.strictEqual(err.statusCode, statusCode);
2331
assert.strictEqual(err.code, code);
@@ -174,7 +182,7 @@ describe('Part size tests with object head', () => {
174182

175183
it('should return an error when requesting part 2 of empty object', done => {
176184
headObject({ Key: emptyObject, PartNumber: 2 }, (err, data) => {
177-
checkError(err, 416, 'InvalidRange');
185+
checkError(err, 416, 416);
178186
assert.strictEqual(data, null);
179187
done();
180188
});
@@ -183,15 +191,15 @@ describe('Part size tests with object head', () => {
183191
it('should return content-length requesting part 1 of non-MPU object', done => {
184192
headObject({ Key: nonMpuObject, PartNumber: 1 }, (err, data) => {
185193
checkNoError(err);
186-
assert.strictEqual(data.ContentLength, 0);
194+
assert.strictEqual(data.ContentLength, bodySize);
187195
done();
188196
});
189197
});
190198

191199
it('should return an error when requesting part 2 of non-MPU object', done => {
192-
headObject({ Key: nonMpuObject, PartNumber: 1 }, (err, data) => {
193-
checkError(err, 416, 'InvalidRange');
194-
assert.strictEqual(data.ContentLength, bodySize);
200+
headObject({ Key: nonMpuObject, PartNumber: 2 }, (err, data) => {
201+
checkError(err, 416, 416);
202+
assert.strictEqual(data, null);
195203
done();
196204
});
197205
});

0 commit comments

Comments
 (0)