Skip to content

Commit

Permalink
fix: run mdapi NUTs in CI (#431)
Browse files Browse the repository at this point in the history
* fix: run mdapi NUTs in CI

* fix: use latest testkit

* fix: check for NaN in size comparison

* fix: check for NaN in size comparison

* fix: only compare file sizes not directories

Co-authored-by: Shane McLaughlin <[email protected]>
  • Loading branch information
shetzel and mshanemc authored Feb 27, 2022
1 parent 795b6da commit e33fd1e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ workflows:
- 'yarn test:nuts:specialTypes'
- 'yarn test:nuts:deploy:destructive'
- 'yarn test:nuts:tracking'
- 'yarn test:nuts:mdapi'
- release-management/release-package:
sign: true
github-release: true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"@oclif/dev-cli": "^1",
"@oclif/plugin-command-snapshot": "^3.1.2",
"@salesforce/cli-plugins-testkit": "^1.5.3",
"@salesforce/cli-plugins-testkit": "^1.5.12",
"@salesforce/dev-config": "^3.0.0",
"@salesforce/dev-scripts": "^2.0.0",
"@salesforce/plugin-command-reference": "^1.3.18",
Expand Down
33 changes: 21 additions & 12 deletions test/nuts/mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,29 @@ describe('mdapi NUTs', () => {
expect(size1).to.equal(size2);
}
if (srcComp.content) {
const size1 = fs.statSync(srcComp.content).size;
const size2 = fs.statSync(srcComp2.content).size;
// Content files can differ slightly due to compression
expect(size1 / size2).to.be.within(0.98, 1.02);
const stat1 = fs.statSync(srcComp.content);
const stat2 = fs.statSync(srcComp2.content);

if (stat1.isFile()) {
const size1 = stat1.size;
const size2 = stat2.size;
// Content files can differ slightly due to compression so compare
// with a tolerance.
expect(size1 / size2, `file1 size: ${size1} should ~ equal file2 size: ${size2}`).to.be.within(0.98, 1.02);
}
}
}
});
});

describe('mdapi:deploy:cancel', () => {
it('will cancel an mdapi deploy via the stash.json', () => {
execCmd('force:source:convert --outputdir mdapi');
const deploy = execCmd<{ id: string }>('force:mdapi:beta:deploy -d mdapi -w 0 --json', {
const convertDir = 'mdConvert1';
execCmd(`force:source:convert --outputdir ${convertDir}`, { ensureExitCode: 0 });
const deploy = execCmd<{ id: string }>(`force:mdapi:beta:deploy -d ${convertDir} -w 0 --json`, {
ensureExitCode: 0,
}).jsonOutput;
const result = execCmd<DeployCancelCommandResult>('force:mdapi:deploy:cancel --json');
expect(result.jsonOutput.status).to.equal(0);
const result = execCmd<DeployCancelCommandResult>('force:mdapi:deploy:cancel --json', { ensureExitCode: 0 });
const json = result.jsonOutput.result;
expect(json).to.have.property('canceledBy');
expect(json).to.have.property('status');
Expand All @@ -198,14 +204,17 @@ describe('mdapi NUTs', () => {
});

it('will cancel an mdapi deploy via the specified deploy id', () => {
execCmd('force:source:convert --outputdir mdapi');
const deploy = execCmd<{ id: string }>('force:mdapi:beta:deploy -d mdapi -w 0 --json', {
const convertDir = 'mdConvert2';
execCmd(`force:source:convert --outputdir ${convertDir}`, { ensureExitCode: 0 });
const deploy = execCmd<{ id: string }>(`force:mdapi:beta:deploy -d ${convertDir} -w 0 --json`, {
ensureExitCode: 0,
}).jsonOutput;
expect(deploy.result).to.have.property('id');

const result = execCmd<DeployCancelCommandResult>(`force:mdapi:deploy:cancel --json --jobid ${deploy.result.id}`);
expect(result.jsonOutput.status).to.equal(0);
const result = execCmd<DeployCancelCommandResult>(
`force:mdapi:deploy:cancel --json --jobid ${deploy.result.id}`,
{ ensureExitCode: 0 }
);
const json = result.jsonOutput.result;
expect(json).to.have.property('canceledBy');
expect(json).to.have.property('status');
Expand Down
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@
mv "~2"
safe-json-stringify "~1"

"@salesforce/cli-plugins-testkit@^1.2.0", "@salesforce/cli-plugins-testkit@^1.5.3":
"@salesforce/cli-plugins-testkit@^1.2.0":
version "1.5.3"
resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-1.5.3.tgz#7a1f5e58708e5810de86f2c1a117d7e0c86e79b5"
integrity sha512-watr4Dv6/pYaax+wLbAyZzmPhwkXwC62ERv370jG6064GUWXx/kdoJVEq1FFx8/cijszeWJaOyRGPpDRIss+hg==
Expand All @@ -708,6 +708,20 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.6.0"

"@salesforce/cli-plugins-testkit@^1.5.12":
version "1.5.12"
resolved "https://registry.npmjs.org/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-1.5.12.tgz#e52631814a6cfba5ed08eeb065b214c36acd5597"
integrity sha512-GtEXgyUkF+begT49u4BsliEtDG/siGtE4ErTql7y36pptyGjsLAIWxX+0Iu1yVZzlxA4EmXMSCte/SD0iDDD4w==
dependencies:
"@salesforce/core" "^2.24.0"
"@salesforce/kit" "^1.5.13"
"@salesforce/ts-types" "^1.5.17"
archiver "^5.2.0"
debug "^4.3.1"
shelljs "^0.8.4"
strip-ansi "6.0.1"
ts-retry-promise "^0.6.0"

"@salesforce/command@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@salesforce/command/-/command-2.2.0.tgz#316097f8defd300a93a3460dea3fe31e7d958254"
Expand Down

0 comments on commit e33fd1e

Please sign in to comment.