Skip to content

Commit

Permalink
Merge pull request #486 from forcedotcom/sh/qa/466
Browse files Browse the repository at this point in the history
feat: set additional fields to PackageVersionCreateRequestResult
  • Loading branch information
shetzel authored Jan 12, 2024
2 parents fb8d8ac + 4d68a39 commit 1d17733
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/interfaces/packagingInterfacesAndType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type PackageVersionCreateRequestResult = {
Id: string;
Status: Package2VersionStatus;
Package2Id: string;
Package2Name: string | null;
Package2VersionId: string;
SubscriberPackageVersionId: string | null;
Tag: string;
Expand All @@ -73,6 +74,7 @@ export type PackageVersionCreateRequestResult = {
Error: any[];
CreatedDate: string;
HasMetadataRemoved: boolean | null;
HasPassedCodeCoverageCheck: boolean | null;
CreatedBy: string;
ConvertedFromVersionId: string | null;
};
Expand Down
9 changes: 7 additions & 2 deletions src/package/packageVersionCreateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/packaging', 'package_version_create');

const QUERY =
'SELECT Id, Status, Package2Id, Package2VersionId, Package2Version.SubscriberPackageVersionId, Tag, Branch, ' +
'SELECT Id, Status, Package2Id, Package2.Name, Package2VersionId, Package2Version.SubscriberPackageVersionId, Package2Version.HasPassedCodeCoverageCheck, Tag, Branch, ' +
'CreatedDate, Package2Version.HasMetadataRemoved, CreatedById, IsConversionRequest, Package2Version.ConvertedFromVersionId ' +
'FROM Package2VersionCreateRequest ' +
'%s' + // WHERE, if applicable
Expand Down Expand Up @@ -66,14 +66,17 @@ async function query(query: string, connection: Connection): Promise<PackageVers
Schema & {
Package2Version: Pick<
PackagingSObjects.Package2Version,
'HasMetadataRemoved' | 'SubscriberPackageVersionId' | 'ConvertedFromVersionId'
'HasMetadataRemoved' | 'SubscriberPackageVersionId' | 'ConvertedFromVersionId' | 'HasPassedCodeCoverageCheck'
>;
} & {
Package2: Pick<PackagingSObjects.Package2, 'Name'>;
};
const queryResult = await connection.autoFetchQuery<QueryRecord>(query, { tooling: true });
return (queryResult.records ? queryResult.records : []).map((record) => ({
Id: record.Id,
Status: record.Status,
Package2Id: record.Package2Id,
Package2Name: record.Package2 != null ? record.Package2.Name : null,
Package2VersionId: record.Package2VersionId,
SubscriberPackageVersionId:
record.Package2Version != null ? record.Package2Version.SubscriberPackageVersionId : null,
Expand All @@ -82,6 +85,8 @@ async function query(query: string, connection: Connection): Promise<PackageVers
Error: [],
CreatedDate: formatDate(new Date(record.CreatedDate)),
HasMetadataRemoved: record.Package2Version != null ? record.Package2Version.HasMetadataRemoved : null,
HasPassedCodeCoverageCheck:
record.Package2Version != null ? record.Package2Version.HasPassedCodeCoverageCheck : null,
CreatedBy: record.CreatedById,
ConvertedFromVersionId: convertedFromVersionMessage(record.Status, record.Package2Version?.ConvertedFromVersionId),
}));
Expand Down
4 changes: 4 additions & 0 deletions test/package/packageConvert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ describe('packageConvert', () => {
HasMetadataRemoved: null,
Id: '0Ho3i000000Gmj6YYY',
Package2Id: '0Ho4p0000004DdnCAE',
Package2Name: null,
HasPassedCodeCoverageCheck: null,
Package2VersionId: '05i4p0000004H7lAAE',
Status: 'Success',
SubscriberPackageVersionId: null,
Expand All @@ -258,8 +260,10 @@ describe('packageConvert', () => {
CreatedDate: 'NaN-NaN-NaN NaN:NaN',
Error: [],
HasMetadataRemoved: null,
HasPassedCodeCoverageCheck: null,
Id: '0Ho3i000000Gmj6YYa',
Package2Id: undefined,
Package2Name: null,
Package2VersionId: undefined,
Status: 'inProgress',
SubscriberPackageVersionId: null,
Expand Down
32 changes: 4 additions & 28 deletions test/package/packageTest.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ const VERSION_CREATE_RESPONSE_KEYS = [
'Id',
'Status',
'Package2Id',
'Package2Name',
'Package2VersionId',
'SubscriberPackageVersionId',
'Tag',
'Branch',
'Error',
'CreatedDate',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'CreatedBy',
'ConvertedFromVersionId',
];
Expand Down Expand Up @@ -346,20 +348,7 @@ describe('Integration tests for @salesforce/packaging library', () => {
result.map((res) => {
// we should've filtered to only successful package versions1
expect(res.Status).to.equal('Success');
expect(res).to.have.all.keys(
'Id',
'Status',
'Package2Id',
'Package2VersionId',
'SubscriberPackageVersionId',
'Tag',
'Branch',
'Error',
'CreatedDate',
'HasMetadataRemoved',
'CreatedBy',
'ConvertedFromVersionId'
);
expect(res).to.have.all.keys(VERSION_CREATE_RESPONSE_KEYS);
expect(res.Id.startsWith('08c')).to.be.true;
expect(res.Package2Id.startsWith('0Ho')).to.be.true;
expect(res.Package2VersionId.startsWith('05i')).to.be.true;
Expand All @@ -372,20 +361,7 @@ describe('Integration tests for @salesforce/packaging library', () => {
createdlastdays: 3,
});
expect(result).to.have.length.at.least(1);
expect(result[0]).to.have.all.keys(
'Id',
'Status',
'Package2Id',
'Package2VersionId',
'SubscriberPackageVersionId',
'Tag',
'Branch',
'Error',
'CreatedDate',
'HasMetadataRemoved',
'CreatedBy',
'ConvertedFromVersionId'
);
expect(result[0]).to.have.all.keys(VERSION_CREATE_RESPONSE_KEYS);
const createdDate = new Date(result[0].CreatedDate);
const currentDate = new Date();
expect(currentDate > createdDate).to.be.true;
Expand Down
34 changes: 34 additions & 0 deletions test/package/packageVersionCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -188,8 +190,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -214,8 +218,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down Expand Up @@ -244,8 +250,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -272,8 +280,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -299,8 +309,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -327,8 +339,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -348,8 +362,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down Expand Up @@ -393,8 +409,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down Expand Up @@ -438,8 +456,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down Expand Up @@ -481,8 +501,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -503,8 +525,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -525,8 +549,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand All @@ -552,8 +578,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down Expand Up @@ -698,8 +726,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down Expand Up @@ -764,8 +794,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down Expand Up @@ -842,8 +874,10 @@ describe('Package Version Create', () => {
'CreatedDate',
'Error',
'HasMetadataRemoved',
'HasPassedCodeCoverageCheck',
'Id',
'Package2Id',
'Package2Name',
'Package2VersionId',
'Status',
'SubscriberPackageVersionId',
Expand Down

0 comments on commit 1d17733

Please sign in to comment.