Skip to content

Commit

Permalink
fix: include line/col numbers in deploy failures (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored Oct 9, 2023
1 parent 1ccb851 commit dc6320f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/client/metadataApiDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export class DeployResult implements MetadataTransferResult {
? {
error: c.problem,
problemType: c.problemType,
columnNumber: c.columnNumber ? parseInt(c.columnNumber, 10) : undefined,
lineNumber: c.lineNumber ? parseInt(c.lineNumber, 10) : undefined,
}
: {}),
fullName: c.fullName,
Expand Down
48 changes: 48 additions & 0 deletions test/client/metadataApiDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,54 @@ describe('MetadataApiDeploy', () => {
expect(responses).to.deep.equal(expected);
});

it('should return line/col numbers for mdapi deploy', () => {
const component = matchingContentFile.COMPONENT;
const { fullName, type } = component;
const problem = 'something went wrong';
const problemType = 'Error';
const apiStatus: Partial<MetadataApiDeployStatus> = {
details: {
componentFailures: [
{
changed: 'false',
created: 'false',
deleted: 'false',
success: 'false',
lineNumber: '3',
columnNumber: '5',
problem,
problemType,
fullName,
fileName: component.content,
componentType: type.name,
} as DeployMessage,
{
changed: 'false',
created: 'false',
deleted: 'false',
success: 'false',
lineNumber: '12',
columnNumber: '3',
problem,
problemType,
fullName,
fileName: component.content,
componentType: type.name,
} as DeployMessage,
],
},
};
// intentionally don't include the componentSet
const result = new DeployResult(apiStatus as MetadataApiDeployStatus);
const fileResponses = result.getFileResponses();
assert(fileResponses[0].state === ComponentStatus.Failed);
expect(fileResponses[0].lineNumber).equal(3);
expect(fileResponses[0].columnNumber).equal(5);
assert(fileResponses[1].state === ComponentStatus.Failed);
expect(fileResponses[1].lineNumber).equal(12);
expect(fileResponses[1].columnNumber).equal(3);
});

it('should aggregate diagnostics for a component', () => {
const component = matchingContentFile.COMPONENT;
const deployedSet = new ComponentSet([component]);
Expand Down

0 comments on commit dc6320f

Please sign in to comment.