Skip to content

Commit

Permalink
Add tests for needOplogUpdate
Browse files Browse the repository at this point in the history
Issue: CLDSRV-560
  • Loading branch information
francoisferrand committed Jan 10, 2025
1 parent b155c35 commit 5a0e486
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/unit/api/objectPut.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 5a0e486

Please sign in to comment.