Skip to content

Commit f2048f3

Browse files
committed
Add tests
Issue: CLDSRV-613
1 parent 4c022b6 commit f2048f3

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

tests/unit/api/apiUtils/coldStorage.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,16 @@ describe('cold storage', () => {
243243
done();
244244
});
245245
});
246+
247+
it('should fail if _updateRestoreInfo fails', done => {
248+
const objectMd = new ObjectMD().setDataStoreName(
249+
'location-dmf-v1'
250+
).setArchive(false).getValue();
251+
252+
startRestore(objectMd, { days: 7 }, log, err => {
253+
assert.deepStrictEqual(err, errors.InternalError);
254+
done();
255+
});
256+
});
246257
});
247258
});

tests/unit/api/objectDelete.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const bucketPutACL = require('../../../lib/api/bucketPutACL');
88
const constants = require('../../../constants');
99
const { cleanup, DummyRequestLogger, makeAuthInfo } = require('../helpers');
1010
const objectPut = require('../../../lib/api/objectPut');
11-
const { objectDelete } = require('../../../lib/api/objectDelete');
11+
const { objectDelete, objectDeleteInternal } = require('../../../lib/api/objectDelete');
1212
const objectGet = require('../../../lib/api/objectGet');
1313
const DummyRequest = require('../DummyRequest');
1414
const mpuUtils = require('../utils/mpuUtils');
@@ -210,6 +210,38 @@ describe('objectDelete API', () => {
210210
});
211211
});
212212

213+
it('should log when expiration is trying to delete a master version', done => {
214+
const warnStub = sinon.stub(log, 'warn');
215+
const testBucketPutVersionRequest = new DummyRequest({
216+
bucketName,
217+
namespace,
218+
headers: { 'x-amz-bucket-object-lock-enabled': 'true' },
219+
url: `/${bucketName}`,
220+
});
221+
222+
bucketPut(authInfo, testBucketPutVersionRequest, log, () => {
223+
objectPut(authInfo, testPutObjectRequest,
224+
undefined, log, (err, data) => {
225+
const deleteObjectVersionRequest = new DummyRequest({
226+
bucketName,
227+
namespace,
228+
objectKey,
229+
headers: {},
230+
url: `/${bucketName}/${objectKey}?versionId=${data['x-amz-version-id']}`,
231+
query: {
232+
versionId: data['x-amz-version-id'],
233+
},
234+
});
235+
objectDeleteInternal(authInfo, deleteObjectVersionRequest, log, true, err => {
236+
assert.strictEqual(err, null);
237+
sinon.assert.calledWith(warnStub, 'expiration is trying to delete a master version ' +
238+
'of an object with versioning enabled');
239+
done();
240+
});
241+
});
242+
});
243+
});
244+
213245
describe('with \'modified\' headers', () => {
214246
beforeEach(done => {
215247
bucketPut(authInfo, testBucketPutRequest, log, () => {

0 commit comments

Comments
 (0)