Skip to content

Commit

Permalink
Merge pull request #623 from salesforcecli/wr/printDeployErrors
Browse files Browse the repository at this point in the history
fix: print errors from server
  • Loading branch information
iowillhoit authored May 26, 2023
2 parents 1c97017 + 8d77997 commit c886c3b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/formatters/deployResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import * as path from 'path';
import * as fs from 'fs';
import { ux } from '@oclif/core';
import { dim, underline, bold } from 'chalk';
import { DeployResult, Failures, FileResponse, RequestStatus, Successes } from '@salesforce/source-deploy-retrieve';
import {
DeployResult,
Failures,
FileResponse,
FileResponseFailure,
RequestStatus,
Successes,
} from '@salesforce/source-deploy-retrieve';
import { Org, SfError } from '@salesforce/core';
import { ensureArray } from '@salesforce/kit';
import {
Expand Down Expand Up @@ -234,6 +241,17 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
if (this.result.response.status === RequestStatus.Succeeded) return;

const failures = this.relativeFiles.filter(isSdrFailure);
// .push returns a number, so push here
failures.push(
...ensureArray(this.result.response.details.componentFailures).map(
(fail) =>
({
problemType: fail.problemType,
fullName: fail.fullName,
error: fail.problem,
} as FileResponseFailure)
)
);
if (!failures.length) return;

const columns = {
Expand Down
24 changes: 24 additions & 0 deletions test/utils/output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as path from 'path';
import { assert, expect, config } from 'chai';
import * as sinon from 'sinon';
import { DeployResult } from '@salesforce/source-deploy-retrieve';
import { ux } from '@oclif/core';
import { getCoverageFormattersOptions } from '../../src/utils/coverage';
import { DeployResultFormatter } from '../../src/formatters/deployResultFormatter';
import { getDeployResult } from './deployResponses';
Expand All @@ -21,6 +22,29 @@ describe('deployResultFormatter', () => {
sandbox.restore();
});

describe('displayFailures', () => {
const deployResultFailure = getDeployResult('failed');
const tableStub = sandbox.stub(ux, 'table');

it('prints file responses, and messages from server', () => {
const formatter = new DeployResultFormatter(deployResultFailure, { verbose: true });
formatter.display();
expect(tableStub.callCount).to.equal(1);
expect(tableStub.firstCall.args[0]).to.deep.equal([
{
error: 'This component has some problems',
fullName: 'ProductController',
problemType: 'Error',
},
{
error: 'This component has some problems',
fullName: 'ProductController',
problemType: 'Error',
},
]);
});
});

describe('coverage functions', () => {
describe('getCoverageFormattersOptions', () => {
it('clover, json', () => {
Expand Down

0 comments on commit c886c3b

Please sign in to comment.