Skip to content

Commit

Permalink
fix: quick deploy polling uses the new deploy ID
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Nov 16, 2023
1 parent d481ac1 commit 567d6f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/commands/project/deploy/quick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,13 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
const deployOpts = cache.get(jobId) ?? ({} as DeployOptions);
const org = flags['target-org'] ?? (await Org.create({ aliasOrUsername: deployOpts['target-org'] }));
const api = await resolveApi(this.configAggregator);
const connection = org.getConnection(flags['api-version']);

const mdapiDeploy = new MetadataApiDeploy({
usernameOrConnection: org.getConnection(flags['api-version']),
// This is the ID of the deploy (of the validated metadata)
const deployId = await connection.metadata.deployRecentValidation({
id: jobId,
apiOptions: {
rest: api === API['REST'],
},
rest: api === API['REST'],
});
// This is the ID of the deploy (of the validated metadata)
const deployId = await mdapiDeploy.deployRecentValidation(api === API['REST']);
this.log(`Deploy ID: ${chalk.bold(deployId)}`);

if (flags.async) {
Expand All @@ -109,6 +106,13 @@ export default class DeployMetadataQuick extends SfCommand<DeployResultJson> {
return asyncFormatter.getJson();
}

const mdapiDeploy = new MetadataApiDeploy({
usernameOrConnection: connection,
id: deployId,
apiOptions: {
rest: api === API['REST'],
},
});
const result = await mdapiDeploy.pollStatus({
frequency: Duration.seconds(1),
timeout: flags.wait,
Expand Down
22 changes: 21 additions & 1 deletion test/commands/deploy/metadata/quick.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('deploy metadata quick NUTs', () => {
});

describe('--job-id', () => {
it('should deploy previously validated deployment', async () => {
it('should deploy previously validated deployment (async)', async () => {
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
args: '--source-dir force-app',
json: true,
Expand All @@ -97,6 +97,26 @@ describe('deploy metadata quick NUTs', () => {
exitCode: 0,
});
assert(deploy);
assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID');
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
});

it('should deploy previously validated deployment (poll)', async () => {
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
args: '--source-dir force-app',
json: true,
exitCode: 0,
});
assert(validation);
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);

const deploy = await testkit.execute<DeployResultJson>('project:deploy:quick', {
args: `--job-id ${validation.result.id} --wait 20`,
json: true,
exitCode: 0,
});
assert(deploy);
assert(deploy.result.id !== validation.result.id, 'deploy result ID should not be the validation ID');
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
});

Expand Down

0 comments on commit 567d6f5

Please sign in to comment.