Skip to content

Commit

Permalink
fix: don't cast opts to boolean (#862)
Browse files Browse the repository at this point in the history
* fix: don't cast opts to boolean

* test(nut): deploy empty manifest

* test: fix deploy nut
  • Loading branch information
cristiand391 authored Jan 5, 2024
1 parent 8aa4e58 commit cbffe96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/



import { ConfigAggregator, Messages, Org, SfError, SfProject } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { Nullable } from '@salesforce/ts-types';
Expand All @@ -26,7 +24,7 @@ import { DEPLOY_STATUS_CODES } from './errorCodes.js';
import { DeployCache } from './deployCache.js';
import { writeManifest } from './manifestCache.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
export const cacheMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'cache');

const deployMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata');
Expand Down Expand Up @@ -156,7 +154,7 @@ export async function executeDeploy(
});
componentSet = await buildComponentSet(opts, stl);
if (componentSet.size === 0) {
if (Boolean(opts['source-dir']) ?? Boolean(opts.manifest) ?? Boolean(opts.metadata) ?? throwOnEmpty) {
if (opts['source-dir'] ?? opts.manifest ?? opts.metadata ?? throwOnEmpty) {
// the user specified something to deploy, but there isn't anything
throw new SfError(
deployMessages.getMessage('error.nothingToDeploy'),
Expand Down
21 changes: 21 additions & 0 deletions test/nuts/deploy/metadata.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,47 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { join } from 'node:path';
import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { expect } from 'chai';
import { SourceTestkit } from '@salesforce/source-testkit';
import { DeployResultJson } from '../../../src/utils/types.js';

const packageXml = `<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>59.0</version>
</Package>
`;

describe('deploy metadata NUTs', () => {
let testkit: SourceTestkit;
const packageFile = 'package.xml';
let xmlPath: string | undefined;

before(async () => {
testkit = await SourceTestkit.create({
repository: 'https://github.com/trailheadapps/dreamhouse-lwc.git',
nut: fileURLToPath(import.meta.url),
});
await testkit.deploy({ args: '--source-dir force-app', exitCode: 0 });
xmlPath = join(testkit.projectDir, packageFile);
await fs.promises.writeFile(xmlPath, packageXml);
});

after(async () => {
await testkit?.clean();
});

it('should throw if component set is empty', async () => {
try {
await testkit.deploy({ args: '--manifest package.xml --dry-run', json: true, exitCode: 1 });
} catch (e) {
const err = e as Error;
expect(err.name).to.equal('NothingToDeploy');
}
});

it('should deploy ApexClasses from wildcard match (single character)', async () => {
const response = await testkit.deploy({ args: '--metadata "ApexClass:P*"' });
expect(response?.status).to.equal(0);
Expand Down

0 comments on commit cbffe96

Please sign in to comment.