Skip to content

Commit

Permalink
chore: revert --use-most-recent default change, skip NUTs
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Jun 28, 2023
1 parent 39b3d76 commit 7279ceb
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 1 deletion.
25 changes: 25 additions & 0 deletions test/commands/deploy/metadata/cancel.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ describe('deploy metadata cancel NUTs', () => {
expect(cancel.jsonOutput.name).to.equal('CannotCancelDeployError');
}
});

it.skip('should cancel most recently started deployment without specifying the flag', () => {
const first = execCmd<DeployResultJson>(
'deploy:metadata --source-dir force-app --async --ignore-conflicts --json',
{
ensureExitCode: 0,
}
).jsonOutput?.result;
assert(first);
assert(first.id);

const cacheBefore = readDeployCache(session.dir);
expect(cacheBefore).to.have.property(first.id);

const cancel = execCmd<DeployResultJson>('deploy:metadata:cancel --json');
assert(cancel.jsonOutput);
if (cancel.jsonOutput.status === 0) {
assert(cancel.jsonOutput.result);
assertSuccessfulCancel(session.dir, first, cancel.jsonOutput.result);
} else {
// the deploy likely already finished
expect(cancel.jsonOutput.exitCode).to.equal(1);
expect(cancel.jsonOutput.name).to.equal('CannotCancelDeployError');
}
});
});

describe('--job-id', () => {
Expand Down
17 changes: 17 additions & 0 deletions test/commands/deploy/metadata/quick.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ describe('deploy metadata quick NUTs', () => {
assert(deploy);
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
});

it.skip('should deploy previously validated deployment without specifying the flag', 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', {
json: true,
exitCode: 0,
});
assert(deploy);
await testkit.expect.filesToBeDeployed(['force-app/**/*'], ['force-app/test/**/*']);
});
it('should deploy previously validated deployment with metadata format', async () => {
execCmd('project:convert:source --source-dir force-app --output-dir metadata');
const validation = await testkit.execute<DeployResultJson>('project:deploy:validate', {
Expand Down
15 changes: 15 additions & 0 deletions test/commands/deploy/metadata/report-mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ describe('deploy metadata report NUTs with source-dir', () => {
assert(deploy?.result);
expect(deploy.result.success).to.equal(true);
});

it.skip('should report most recently started deployment without specifying the flag', async () => {
await testkit.execute<DeployResultJson>('project deploy start', {
args: '--metadata-dir mdapiOut --async',
json: true,
exitCode: 0,
});

const deploy = await testkit.execute<DeployResultJson>('project deploy report', {
json: true,
exitCode: 0,
});
assert(deploy?.result);
expect(deploy.result.success).to.equal(true);
});
});

describe('--job-id', () => {
Expand Down
42 changes: 42 additions & 0 deletions test/commands/deploy/metadata/report.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as fs from 'fs';
import * as path from 'path';
import { SourceTestkit } from '@salesforce/source-testkit';
import { assert, isObject } from '@salesforce/ts-types';
import { expect } from 'chai';
import { DeployResultJson } from '../../../../src/utils/types';

describe('deploy metadata report NUTs with source-dir', () => {
Expand Down Expand Up @@ -39,6 +42,21 @@ describe('deploy metadata report NUTs with source-dir', () => {
assert(isObject(deploy));
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);
});

it.skip('should report most recently started deployment without specifying the flag', async () => {
await testkit.execute<DeployResultJson>('deploy:metadata', {
args: '--source-dir force-app --async',
json: true,
exitCode: 0,
});

const deploy = await testkit.execute<DeployResultJson>('deploy:metadata:report', {
json: true,
exitCode: 0,
});
assert(isObject(deploy));
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);
});
});

describe('--job-id', () => {
Expand All @@ -57,4 +75,28 @@ describe('deploy metadata report NUTs with source-dir', () => {
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);
});
});

describe('test flags', () => {
it('should override the --output-dir', async () => {
const first = await testkit.execute<DeployResultJson>('deploy:metadata', {
args: '--source-dir force-app --async --ignore-conflicts --test-level RunAllTestsInOrg --coverage-formatters html --junit --results-dir test-output',
json: true,
exitCode: 0,
});
const deploy = await testkit.execute<DeployResultJson>('deploy:metadata:report', {
args: `--job-id ${first?.result.id} --coverage-formatters html --coverage-formatters text --junit --results-dir test-output-override`,
json: true,
exitCode: 0,
});
expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override'))).to.be.true;
expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'coverage'))).to.be.true;
expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'coverage', 'html'))).to.be.true;
expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'coverage', 'text.txt'))).to.be.true;
expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'junit'))).to.be.true;
expect(fs.existsSync(path.join(testkit.projectDir, 'test-output-override', 'junit', 'junit.xml'))).to.be.true;
expect(fs.existsSync(path.join(testkit.projectDir, 'test-output'))).to.be.false;
assert(isObject(deploy));
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);
});
});
});
25 changes: 25 additions & 0 deletions test/commands/deploy/metadata/resume.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,31 @@ describe('deploy metadata resume NUTs', () => {

const cacheAfter = readDeployCache(testkit.projectDir);

expect(cacheAfter).to.have.property(first.result.id);
expect(cacheAfter[first.result.id]).have.property('status');
expect(cacheAfter[first.result.id].status).to.equal(RequestStatus.Succeeded);
});
it.skip('should resume most recently started deployment without specifying the flag', async () => {
const first = await testkit.execute<DeployResultJson>('deploy:metadata', {
args: '--source-dir force-app --async',
json: true,
exitCode: 0,
});
assert(first);
assert(first.result.id);

const cacheBefore = readDeployCache(testkit.projectDir);
expect(cacheBefore).to.have.property(first.result.id);

const deploy = await testkit.execute<DeployResultJson>('deploy:metadata:resume', {
json: true,
exitCode: 0,
});
assert(deploy);
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);

const cacheAfter = readDeployCache(testkit.projectDir);

expect(cacheAfter).to.have.property(first.result.id);
expect(cacheAfter[first.result.id]).have.property('status');
expect(cacheAfter[first.result.id].status).to.equal(RequestStatus.Succeeded);
Expand Down
33 changes: 32 additions & 1 deletion test/commands/deploy/metadata/validate.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as path from 'path';
import { SourceTestkit } from '@salesforce/source-testkit';
import { isObject } from '@salesforce/ts-types';
import { assert } from 'chai';
import { assert, expect } from 'chai';
import { execCmd } from '@salesforce/cli-plugins-testkit';
import { DeployResultJson } from '../../../../src/utils/types';

describe('deploy metadata validate NUTs', () => {
Expand Down Expand Up @@ -35,4 +37,33 @@ describe('deploy metadata validate NUTs', () => {
await testkit.expect.filesToBeDeployedViaResult(['force-app/**/*'], ['force-app/test/**/*'], deploy.result.files);
});
});

describe('destructive flags', () => {
it('should validate deploy with destructive changes', async () => {
// create package.xml
execCmd('project generate manifest -p force-app');

// create preDestructiveChanges.xml
execCmd(`project generate manifest -p ${path.join('my-app', 'apex')} --type pre`);

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

// ensure the post-destructive-changes flag works as well
const deployPost = await testkit.execute<DeployResultJson>('project:deploy:validate', {
args: '--manifest package.xml --post-destructive-changes destructiveChangesPre.xml',
json: true,
exitCode: 0,
});
expect(deployPost?.result.success).to.be.true;
expect(deployPost?.result.numberComponentsDeployed).to.equal(12);
expect(deployPost?.result.checkOnly).to.be.true;
});
});
});

0 comments on commit 7279ceb

Please sign in to comment.