Skip to content

Commit

Permalink
Merge pull request #803 from salesforcecli/sh/ignore-warnings-on-vali…
Browse files Browse the repository at this point in the history
…date

fix: add ignore-warnings flag to deploy validate
  • Loading branch information
WillieRuemmele authored Nov 8, 2023
2 parents 46c3625 + 32c0622 commit 7cd4da5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"async",
"concise",
"coverage-formatters",
"ignore-warnings",
"json",
"junit",
"manifest",
Expand All @@ -183,7 +184,7 @@
"wait"
],
"alias": ["deploy:metadata:validate"],
"flagChars": ["a", "d", "l", "m", "o", "t", "w", "x"],
"flagChars": ["a", "d", "g", "l", "m", "o", "t", "w", "x"],
"flagAliases": []
},
{
Expand Down
6 changes: 6 additions & 0 deletions src/commands/project/deploy/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export default class DeployMetadataValidate extends SfCommand<DeployResultJson>
helpValue: '<minutes>',
min: 1,
}),
'ignore-warnings': Flags.boolean({
char: 'g',
summary: deployMessages.getMessage('flags.ignore-warnings.summary'),
description: deployMessages.getMessage('flags.ignore-warnings.description'),
default: false,
}),
'coverage-formatters': { ...coverageFormattersFlag, helpGroup: testFlags },
junit: Flags.boolean({
summary: messages.getMessage('flags.junit.summary'),
Expand Down
30 changes: 30 additions & 0 deletions test/commands/deploy/metadata/validate.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,35 @@ describe('deploy metadata validate NUTs', () => {
expect(deployPost?.result.numberComponentsDeployed).to.equal(12);
expect(deployPost?.result.checkOnly).to.be.true;
});

it('should validate deploy with destructive changes and --ignore-warnings', async () => {
// If you try to delete something in the org that isn't there, a warning is returned
// so this test tries to delete an apex class that isn't in the org.

execCmd('project deploy start -d force-app -d my-app -d foo-bar');
// create package.xml
execCmd('project generate manifest -p force-app');

const destroyXmlContents = `<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>NonExistantClass</members>
<name>ApexClass</name>
</types>
<version>58.0</version>
</Package>`;
// create destroy.xml
await testkit.writeFile(path.join(testkit.projectDir, 'destroy.xml'), destroyXmlContents);

const deploy = await testkit.execute<DeployResultJson>('project:deploy:validate', {
args: '--manifest package.xml --pre-destructive-changes destroy.xml --ignore-warnings',
json: true,
exitCode: 0,
});
expect(deploy?.result.success).to.be.true;
expect(deploy?.result.numberComponentsDeployed).to.equal(10);
expect(deploy?.result.checkOnly).to.be.true;
expect(deploy?.result.ignoreWarnings).to.be.true;
});
});
});

0 comments on commit 7cd4da5

Please sign in to comment.