diff --git a/tests/unit/api/objectPut.js b/tests/unit/api/objectPut.js index 34f2a32f5d..c5044199f3 100644 --- a/tests/unit/api/objectPut.js +++ b/tests/unit/api/objectPut.js @@ -671,6 +671,76 @@ describe('objectPut API', () => { }); }); }); + + it('should not pass needOplogUpdate when writing new object', done => { + async.series([ + next => bucketPut(authInfo, testPutBucketRequest, log, next), + next => objectPut(authInfo, testPutObjectRequest, undefined, log, next), + async () => { + sinon.assert.calledWith(metadata.putObjectMD.lastCall, + bucketName, objectName, any, sinon.match({ + needOplogUpdate: undefined, + originOp: undefined, + }), any, any); + }, + ], done); + }); + + it('should not pass needOplogUpdate when replacing object', done => { + async.series([ + next => bucketPut(authInfo, testPutBucketRequest, log, next), + next => objectPut(authInfo, testPutObjectRequest, undefined, log, next), + next => objectPut(authInfo, testPutObjectRequest, undefined, log, next), + async () => { + sinon.assert.calledWith(metadata.putObjectMD.lastCall, + bucketName, objectName, any, sinon.match({ + needOplogUpdate: undefined, + originOp: undefined, + }), any, any); + }, + ], done); + }); + + it('should pass needOplogUpdate to metadata when replacing archived object', done => { + const archived = { + archiveInfo: { foo: 0, bar: 'stuff' } + }; + + async.series([ + next => bucketPut(authInfo, testPutBucketRequest, log, next), + next => objectPut(authInfo, testPutObjectRequest, undefined, log, next), + next => fakeMetadataArchive(bucketName, objectName, undefined, archived, next), + next => objectPut(authInfo, testPutObjectRequest, undefined, log, next), + async () => { + sinon.assert.calledWith(metadata.putObjectMD.lastCall, + bucketName, objectName, any, sinon.match({ + needOplogUpdate: true, + originOp: 's3:ReplaceArchivedObject', + }), any, any); + }, + ], done); + }); + + it('should pass needOplogUpdate to metadata when replacing archived object in version suspended bucket', done => { + const archived = { + archiveInfo: { foo: 0, bar: 'stuff' } + }; + + async.series([ + next => bucketPut(authInfo, testPutBucketRequest, log, next), + next => bucketPutVersioning(authInfo, suspendVersioningRequest, log, next), + next => objectPut(authInfo, testPutObjectRequest, undefined, log, next), + next => fakeMetadataArchive(bucketName, objectName, undefined, archived, next), + next => objectPut(authInfo, testPutObjectRequest, undefined, log, next), + async () => { + sinon.assert.calledWith(metadata.putObjectMD.lastCall, + bucketName, objectName, any, sinon.match({ + needOplogUpdate: true, + originOp: 's3:ReplaceArchivedObject', + }), any, any); + }, + ], done); + }); }); describe('objectPut API with versioning', () => {