Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print errors from server #623

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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