Skip to content
Merged
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions test/commands/deploy/metadata.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@
*/

import { fileURLToPath } from 'node:url';
import { join } from 'node:path';
import { readdir } from 'node:fs/promises';
import { SourceTestkit } from '@salesforce/source-testkit';
import { expect } from 'chai';

async function getAllFilePaths(dir: string): Promise<string[]> {
let filePaths: string[] = [];
const entries = await readdir(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = join(dir, entry.name);
if (entry.isFile()) {
filePaths.push(fullPath);
} else if (entry.isDirectory()) {
// eslint-disable-next-line no-await-in-loop
filePaths = filePaths.concat(await getAllFilePaths(fullPath));
}
}
return filePaths;
}

describe('deploy metadata NUTs', () => {
let testkit: SourceTestkit;
Expand All @@ -31,9 +50,19 @@ describe('deploy metadata NUTs', () => {

describe('--metadata flag', () => {
it('should deploy ApexClass', async () => {
process.env.SF_MDAPI_TEMP_DIR = 'myTempDirectory';
await testkit.modifyLocalGlobs(['force-app/main/default/classes/*.cls'], '// comment');
await testkit.deploy({ args: '--metadata ApexClass' });
await testkit.expect.filesToBeDeployed(['force-app/main/default/classes/*']);

// no illegal file paths should be generated when using SF_MDAPI_TEMP_DIR
expect(
(await getAllFilePaths(join(testkit.projectDir, process.env.SF_MDAPI_TEMP_DIR))).every(
(path) => !/[<>:"/\\|?*]/.test(path)
)
).to.be.true;

delete process.env.SF_MDAPI_TEMP_DIR;
});

it('should deploy named ApexClass', async () => {
Expand Down
Loading