Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ignore-warnings flag to deploy validate #803

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
shetzel marked this conversation as resolved.
Show resolved Hide resolved
expect(deploy?.result.numberComponentsDeployed).to.equal(10);
expect(deploy?.result.checkOnly).to.be.true;
expect(deploy?.result.ignoreWarnings).to.be.true;
});
});
});