Skip to content

Commit

Permalink
Add custom listing parser to MongoDB listObject
Browse files Browse the repository at this point in the history
test to check for location param is absent

Issue: ARSN-372
  • Loading branch information
KillianG committed Nov 16, 2023
1 parent 2537f8a commit 1760627
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/functional/metadata/mongodb/listObject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,36 @@ describe('MongoClientInterface::metadata.listObject', () => {
{ upsert: false }).then(() => cb()).catch(err => cb(err));
}

function customListingParser(entries) {
return entries.map(entry => {
assert(entry.value.location === undefined);
const tmp = JSON.parse(entry.value);
return {
key: entry.key,
value: {
Size: tmp['content-length'],
ETag: tmp['content-md5'],
VersionId: tmp.versionId,
IsNull: tmp.isNull,
IsDeleteMarker: tmp.isDeleteMarker,
LastModified: tmp['last-modified'],
Owner: {
DisplayName: tmp['owner-display-name'],
ID: tmp['owner-id'],
},
StorageClass: tmp['x-amz-storage-class'],
// MPU listing properties
Initiated: tmp.initiated,
Initiator: tmp.initiator,
EventualStorageBucket: tmp.eventualStorageBucket,
partLocations: tmp.partLocations,
creationDate: tmp.creationDate,
ingestion: tmp.ingestion,
},
};
});
}

beforeAll(done => {
mongoserver.start().then(() => {
mongoserver.waitUntilRunning().then(() => {
Expand All @@ -83,6 +113,7 @@ describe('MongoClientInterface::metadata.listObject', () => {
readPreference: 'primary',
database: DB_NAME,
},
customListingParser,
};
metadata = new MetadataWrapper(IMPL_NAME, opts, null, logger);
metadata.setup(done);
Expand Down Expand Up @@ -152,6 +183,12 @@ describe('MongoClientInterface::metadata.listObject', () => {
objVal: {
key: 'pfx1-test-object',
versionId: 'null',
location: [{
start: 0,
size: 150,
dataStoreETag: 'etag',
dataStoreVersionId: 'versionId',
}],
},
nbVersions: 5,
};
Expand Down Expand Up @@ -200,6 +237,7 @@ describe('MongoClientInterface::metadata.listObject', () => {
assert.strictEqual(data.Contents[0].key, 'pfx1-test-object');
assert.strictEqual(data.Contents[1].key, 'pfx2-test-object');
assert.strictEqual(data.Contents[2].key, 'pfx3-test-object');
assert.strictEqual(data.Contents[0].value.location, undefined);
return done();
});
});
Expand Down

0 comments on commit 1760627

Please sign in to comment.