Skip to content

Commit

Permalink
test: mocks follow real life
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 27, 2024
1 parent 432f585 commit 04afb37
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/client/metadataApiRetrieve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { assert, expect } from 'chai';
import chai = require('chai');
import deepEqualInAnyOrder = require('deep-equal-in-any-order');
import { SinonStub } from 'sinon';
import { getString } from '@salesforce/ts-types';
import { ensureString, getString } from '@salesforce/ts-types';
import fs from 'graceful-fs';
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
import {
Expand Down Expand Up @@ -549,14 +549,14 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
const result = new RetrieveResult(apiStatus as MetadataApiRetrieveStatus, retrievedSet, retrievedSet);

const responses = result.getFileResponses();
const baseResponse: FileResponse = {
const baseResponse = {
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
};
} as const;
const expected: FileResponse[] = [
Object.assign({}, baseResponse, { filePath: component.content }),
Object.assign({}, baseResponse, { filePath: component.xml }),
{ ...baseResponse, filePath: ensureString(component.content) },
{ ...baseResponse, filePath: ensureString(component.xml) },
];

expect(responses).to.deep.equal(expected);
Expand All @@ -572,20 +572,20 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
const result = new RetrieveResult(apiStatus as MetadataApiRetrieveStatus, retrievedSet, localSet);

const responses = result.getFileResponses();
const baseResponse: FileResponse = {
const baseResponse = {
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
};
} as const;
// Since the DECOMPOSED_COMPONENT was in the retrieved ComponentSet but
// not the local source ComponentSet it should have a state of 'Created'
// rather than 'Changed'.
const expected: FileResponse[] = [
Object.assign({}, baseResponse, { filePath: component.content }),
Object.assign({}, baseResponse, { filePath: component.xml }),
{ ...baseResponse, filePath: ensureString(component.content) },
{ ...baseResponse, filePath: ensureString(component.xml) },
{
fullName: DECOMPOSED_COMPONENT.fullName,
filePath: DECOMPOSED_COMPONENT.xml,
filePath: ensureString(DECOMPOSED_COMPONENT.xml),
state: ComponentStatus.Created,
type: DECOMPOSED_COMPONENT.type.name,
},
Expand Down Expand Up @@ -646,7 +646,7 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
state: ComponentStatus.Changed,
fullName: successComponent.fullName,
type: successComponent.type.name,
filePath: successComponent.xml,
filePath: ensureString(successComponent.xml),
},
];

Expand Down Expand Up @@ -695,7 +695,7 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
filePath: component.xml,
filePath: ensureString(component.xml),
},
];

Expand All @@ -721,7 +721,7 @@ hY2thZ2VkL3BhY2thZ2UueG1sUEsFBgAAAAADAAMA7QAAAJoCAAAAAA==`;
state: ComponentStatus.Changed,
fullName: component.fullName,
type: component.type.name,
filePath: component.content,
filePath: ensureString(component.content),
},
];

Expand Down

2 comments on commit 04afb37

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 04afb37 Previous: 870aa3e Ratio
eda-componentSetCreate-linux 186 ms 187 ms 0.99
eda-sourceToMdapi-linux 1947 ms 1969 ms 0.99
eda-sourceToZip-linux 1762 ms 1807 ms 0.98
eda-mdapiToSource-linux 2745 ms 2807 ms 0.98
lotsOfClasses-componentSetCreate-linux 414 ms 446 ms 0.93
lotsOfClasses-sourceToMdapi-linux 3617 ms 3708 ms 0.98
lotsOfClasses-sourceToZip-linux 3121 ms 3054 ms 1.02
lotsOfClasses-mdapiToSource-linux 3434 ms 3495 ms 0.98
lotsOfClassesOneDir-componentSetCreate-linux 619 ms 646 ms 0.96
lotsOfClassesOneDir-sourceToMdapi-linux 6473 ms 6528 ms 0.99
lotsOfClassesOneDir-sourceToZip-linux 5661 ms 5646 ms 1.00
lotsOfClassesOneDir-mdapiToSource-linux 6283 ms 6306 ms 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 04afb37 Previous: 870aa3e Ratio
eda-componentSetCreate-win32 428 ms 412 ms 1.04
eda-sourceToMdapi-win32 3770 ms 3474 ms 1.09
eda-sourceToZip-win32 2967 ms 2685 ms 1.11
eda-mdapiToSource-win32 6170 ms 5744 ms 1.07
lotsOfClasses-componentSetCreate-win32 951 ms 922 ms 1.03
lotsOfClasses-sourceToMdapi-win32 7948 ms 7597 ms 1.05
lotsOfClasses-sourceToZip-win32 4903 ms 4822 ms 1.02
lotsOfClasses-mdapiToSource-win32 7762 ms 7584 ms 1.02
lotsOfClassesOneDir-componentSetCreate-win32 1543 ms 1515 ms 1.02
lotsOfClassesOneDir-sourceToMdapi-win32 13851 ms 13612 ms 1.02
lotsOfClassesOneDir-sourceToZip-win32 8947 ms 8966 ms 1.00
lotsOfClassesOneDir-mdapiToSource-win32 13859 ms 13733 ms 1.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.