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

test: ut for mdapi line/col numbers #1130

Merged
merged 1 commit into from
Oct 9, 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
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
Loading