Skip to content

Commit

Permalink
test: fixing NUTs, not running
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Nov 1, 2023
1 parent be27b8d commit a869052
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@salesforce/core": "^5.3.10",
"@salesforce/kit": "^3.0.14",
"@salesforce/sf-plugins-core": "^4.0.0",
"@salesforce/source-deploy-retrieve": "^9.7.28",
"@salesforce/source-deploy-retrieve": "^9.8.1",
"@salesforce/source-tracking": "^4.2.17",
"chalk": "^5.3.0",
"got": "^13.0.0",
Expand All @@ -19,10 +19,10 @@
"devDependencies": {
"@oclif/plugin-command-snapshot": "^5.0.1",
"@oclif/plugin-help": "^6.0.5",
"@salesforce/cli-plugins-testkit": "^5.0.0-dev.1",
"@salesforce/cli-plugins-testkit": "^5.0.0-dev.2",
"@salesforce/dev-scripts": "^6.0.3",
"@salesforce/plugin-command-reference": "^3.0.25",
"@salesforce/plugin-deploy-retrieve": "^1.19.2",
"@salesforce/plugin-deploy-retrieve": "^1.19.3",
"@salesforce/plugin-info": "^2.6.50",
"@salesforce/plugin-settings": "^1.4.28",
"@salesforce/plugin-templates": "^55.5.14",
Expand Down
2 changes: 1 addition & 1 deletion test/formatters/retrieveResultFormatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { join, relative } from 'node:path';
import * as sinon from 'sinon';
import sinon from 'sinon';
import { expect } from 'chai';
import { FileResponse } from '@salesforce/source-deploy-retrieve';
import { cloneJson, ensureArray } from '@salesforce/kit';
Expand Down
5 changes: 3 additions & 2 deletions test/nuts/generateNuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

import path from 'node:path';
import fs from 'node:fs';
import url from 'node:url';
import shelljs from 'shelljs';
import { RepoConfig, TEST_REPOS_MAP } from './testMatrix.js';

const SEED_FILTER = process.env.PLUGIN_SOURCE_SEED_FILTER ?? '';
const SEED_EXCLUDE = process.env.PLUGIN_SOURCE_SEED_EXCLUDE;

function getSeedFiles(): string[] {
const seedDir = path.join(__dirname, 'seeds');
const seedDir = path.join(path.dirname(url.fileURLToPath(import.meta.url)), 'seeds');
const files = fs.readdirSync(seedDir);
return files
.filter((f) => f.endsWith('.seed.ts'))
Expand All @@ -37,7 +38,7 @@ function generateNut(generatedDir: string, seedName: string, seedContents: strin
}

function generateNuts(): void {
const generatedDir = path.resolve(__dirname, 'generated');
const generatedDir = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), 'generated');
shelljs.rm('-rf', generatedDir);
fs.mkdirSync(generatedDir, { recursive: true });
const seeds = getSeedFiles();
Expand Down
8 changes: 4 additions & 4 deletions test/nuts/mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import fs from 'node:fs';
import path from 'node:path';
import { exec } from 'shelljs';
import shelljs from 'shelljs';
import { expect } from 'chai';
import { execCmd, ExecCmdResult, TestSession } from '@salesforce/cli-plugins-testkit';
import { RequestStatus } from '@salesforce/source-deploy-retrieve';
import { create as createArchive } from 'archiver';
import create from 'archiver';
import {
RetrieveCommandAsyncResult,
RetrieveCommandResult,
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('mdapi NUTs', () => {
before(() => {
// Install the ElectronBranding package in the default org for retrieve commands to use
const pkgInstallCmd = `sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`;
const rv = exec(pkgInstallCmd, { silent: true });
const rv = shelljs.exec(pkgInstallCmd, { silent: true });
expect(rv.code, 'Failed to install ElectronBranding package for tests').to.equal(0);

// Create manifests for retrieve commands to use
Expand Down Expand Up @@ -354,7 +354,7 @@ describe('mdapi NUTs', () => {
// make a mdapi directory from the project
execCmd(`force:source:convert -p force-app --outputdir ${mdapiOut}`, { ensureExitCode: 0 });
// make a zip from that
const zip = createArchive('zip', { zlib: { level: 9 } });
const zip = create('zip', { zlib: { level: 9 } });
const output = fs.createWriteStream(path.join(session.project.dir, `${mdapiOut}.zip`));
zip.pipe(output);
// anywhere not at the root level is fine
Expand Down
12 changes: 7 additions & 5 deletions test/nuts/seeds/retrieve.packagenames.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { SourceTestkit } from '@salesforce/source-testkit';
import { exec } from 'shelljs';
import shelljs from 'shelljs';

const ELECTRON = { id: '04t6A000002zgKSQAY', name: 'ElectronBranding' };
const ESCAPEROOM = { id: '04t0P000000JFs1QAG', name: 'DFXP Escape Room' };
Expand Down Expand Up @@ -36,22 +36,24 @@ context('Retrieve packagenames NUTs', () => {

describe('--packagenames flag', () => {
it('should retrieve an installed package', async () => {
exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });
shelljs.exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });

await testkit.retrieve({ args: `--packagenames "${ELECTRON.name}"` });
await testkit.expect.packagesToBeRetrieved([ELECTRON.name]);
});

it('should retrieve two installed packages', async () => {
exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });
exec(`sfdx force:package:install --noprompt --package ${ESCAPEROOM.id} --wait 5 --json`, { silent: true });
shelljs.exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });
shelljs.exec(`sfdx force:package:install --noprompt --package ${ESCAPEROOM.id} --wait 5 --json`, {
silent: true,
});

await testkit.retrieve({ args: `--packagenames "${ELECTRON.name}, ${ESCAPEROOM.name}"` });
await testkit.expect.packagesToBeRetrieved([ELECTRON.name, ESCAPEROOM.name]);
});

it('should retrieve an installed package and sourcepath', async () => {
exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });
shelljs.exec(`sfdx force:package:install --noprompt --package ${ELECTRON.id} --wait 5 --json`, { silent: true });

await testkit.retrieve({
args: `--packagenames "${ELECTRON.name}" --sourcepath "${path.join('force-app', 'main', 'default', 'apex')}"`,
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,10 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.7.1"

"@salesforce/cli-plugins-testkit@^5.0.0-dev.1":
version "5.0.0-dev.1"
resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-5.0.0-dev.1.tgz#2497f48764b8ba164eb5c6f2d5d5b7475ddc0abc"
integrity sha512-Eq5PCsBICJsjGeXc+rt5T/Z8or7/WgxZKE8xIoGzIcgwkTOojGP1v23kndaBAilr01W9q9Tv4DSnBtq9iuLYeg==
"@salesforce/cli-plugins-testkit@^5.0.0-dev.2":
version "5.0.0-dev.2"
resolved "https://registry.yarnpkg.com/@salesforce/cli-plugins-testkit/-/cli-plugins-testkit-5.0.0-dev.2.tgz#735ebc0e15bec2cced49ebaba937184cbe33d1ee"
integrity sha512-fHvSBBCouzDRHQYif3csXKQ9Yb0esNvl++8+DKCem+CPcqdVgzVGOzF4SAkU+8+ChgkPNAG4Jr4qqHYPEXmoVQ==
dependencies:
"@salesforce/core" "^5.3.10"
"@salesforce/kit" "^3.0.15"
Expand Down Expand Up @@ -1084,7 +1084,7 @@
handlebars "^4.7.8"
tslib "^2"

"@salesforce/plugin-deploy-retrieve@^1.19.2":
"@salesforce/plugin-deploy-retrieve@^1.19.3":
version "1.19.3"
resolved "https://registry.yarnpkg.com/@salesforce/plugin-deploy-retrieve/-/plugin-deploy-retrieve-1.19.3.tgz#b1703e5dd31d1a7605b6324f7eb1c39ad94769aa"
integrity sha512-NA8hUidc7RDmPJRfm7Ntbac1B/W1xGaZ4eZkXU94DYaDTHFTQSwmoazuV14XfgYe+XI2GQD/4r6GCFDDkL1+TA==
Expand Down Expand Up @@ -1187,7 +1187,7 @@
chalk "^4"
inquirer "^8.2.5"

"@salesforce/source-deploy-retrieve@^9.7.24", "@salesforce/source-deploy-retrieve@^9.7.28", "@salesforce/source-deploy-retrieve@^9.8.1":
"@salesforce/source-deploy-retrieve@^9.7.24", "@salesforce/source-deploy-retrieve@^9.8.1":
version "9.8.1"
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-9.8.1.tgz#be19edd97097cdbb535762a5c63c7919042f3e96"
integrity sha512-DMscuGAv/Ls/Vp0wqZmjjxxoaRm/2K7Np3KHvjml8hTop1EvnhmwbwsdLDABb+I1uYE8VtWV9RZV82GVTne3+w==
Expand Down

0 comments on commit a869052

Please sign in to comment.