Skip to content

Commit

Permalink
fixup! fixup! Add test for archive object replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisferrand committed Nov 14, 2024
1 parent 502f29f commit 05da813
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions tests/ctst/steps/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,32 +199,34 @@ async function createBucketWithConfiguration(
}
}

async function putMpuObject(world: Zenko, parts: number = 2, objectName?: string, content?: string) {
async function putMpuObject(world: Zenko, parts: number = 2, objectName: string = `${Utils.randomString()}`, content?: string) {

Check failure on line 202 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

This line has a length of 128. Maximum allowed is 120
const bucketName = world.getSaved<string>('bucketName');
world.resetCommand();
let key = objectName;
if (!key) {
key = `${Utils.randomString()}`;
}
world.addToSaved('objectName', key);
world.logger.debug('Adding mpu object', { objectName: key });
world.addCommandParameter({ key });
world.addCommandParameter({ bucket: world.getSaved<string>('bucketName') });
world.addToSaved('objectName', objectName);
world.logger.debug('Adding mpu object', { objectName: objectName });

Check failure on line 206 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected property shorthand
world.addCommandParameter({ key: objectName });
world.addCommandParameter({ bucket: bucketName });
const userMetadata = world.getSaved<string>('userMetadata');
if (userMetadata) {
world.addCommandParameter({ metadata: JSON.stringify(userMetadata) });
}
const initiateMPUResult = await S3.createMultipartUpload(world.getCommandParameters());
assert.ifError(initiateMPUResult.stderr || initiateMPUResult.err);
world.addCommandParameter({
uploadId: extractPropertyFromResults<string>(initiateMPUResult, 'UploadId')
});
const uploadId = extractPropertyFromResults<string>(initiateMPUResult, 'UploadId');

await uploadSetup(world, 'UploadPart', content);
world.deleteKeyFromCommand('metadata');
const body = world.getSaved<string>('tempFileName');

const uploadedParts = [];
for (let i = 0; i < parts; i++) {
world.resetCommand();
world.addCommandParameter({ key: objectName });
world.addCommandParameter({ bucket: bucketName });
world.addCommandParameter({ partNumber: i+1 });
world.addCommandParameter({ uploadId: uploadId });

Check failure on line 226 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected property shorthand
if (body) {
world.addCommandParameter({ body: body });

Check failure on line 228 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected property shorthand
}

world.logger.info('upload part', { part: i, cliParams: world.getCommandParameters() });

Expand All @@ -239,11 +241,14 @@ async function putMpuObject(world: Zenko, parts: number = 2, objectName?: string

await uploadTeardown(world, 'UploadPart');

world.deleteKeyFromCommand('partNumber');
world.resetCommand();
world.addCommandParameter({ key: objectName });
world.addCommandParameter({ bucket: bucketName });
world.addCommandParameter({ uploadId: uploadId });

Check failure on line 247 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected property shorthand
world.addCommandParameter({ multipartUpload: JSON.stringify({ Parts: uploadedParts }) });
const result = await S3.completeMultipartUpload(world.getCommandParameters());
const versionId = extractPropertyFromResults<string>(result, 'VersionId');
world.saveCreatedObject(key, versionId || '');
world.saveCreatedObject(objectName, versionId || '');
world.setResult(result);
return result;
}
Expand All @@ -254,8 +259,8 @@ async function copyObject(world: Zenko, srcObjectName?: string, dstObjectName?:

world.resetCommand();
world.addCommandParameter({ copySource: `${bucket}/${srcObjectName || world.getSaved<string>('objectName')}`});
world.addCommandParameter({ bucket });
world.addCommandParameter({ key });
world.addCommandParameter({ bucket: bucket });

Check failure on line 262 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected property shorthand
world.addCommandParameter({ key: key });

Check failure on line 263 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected property shorthand

const userMetadata = world.getSaved<string>('userMetadata');
if (userMetadata) {
Expand Down

0 comments on commit 05da813

Please sign in to comment.