Skip to content

Commit

Permalink
fix: fix promote nut test
Browse files Browse the repository at this point in the history
  • Loading branch information
peternhale committed Sep 28, 2022
1 parent 7c98fdb commit 1255c1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/commands/force/package/beta/version/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ export class PackageVersionPromoteCommand extends SfdxCommand {

public async run(): Promise<PackageSaveResult> {
const conn = this.hubOrg.getConnection();
let packageId = getPackageIdFromAlias(this.flags.package, this.project) ?? (this.flags.package as string);

const packageIdFromAlias =
getPackageIdFromAlias(this.flags.package, this.project) ?? (this.flags.package as string);
let packageId = packageIdFromAlias;
// ID can be 04t or 05i at this point
validateId([BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID, BY_LABEL.PACKAGE_VERSION_ID], packageId);

Expand All @@ -70,6 +71,7 @@ export class PackageVersionPromoteCommand extends SfdxCommand {

try {
result = await pkg.promote(packageId);
result.id = packageIdFromAlias.startsWith('04t') ? packageIdFromAlias : result.id;
} catch (e) {
const err = SfError.wrap(e);
if (err.name === 'DUPLICATE_VALUE' && err.message.includes('previously released')) {
Expand Down
4 changes: 2 additions & 2 deletions test/commands/force/package/versionPromoteUpdate.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('package:version:promote / package:version:update', () => {
ensureExitCode: 0,
}).shellOutput.stdout;
expect(result).to.contain('Successfully promoted the package version');
expect(result).to.contain('04t');
expect(result).to.contain('04t', result);
expect(result).to.contain(
'to released. Starting in Winter ‘21, only unlocked package versions that have met the minimum 75% code coverage requirement can be promoted. Code coverage minimums aren’t enforced on org-dependent unlocked packages.'
);
Expand All @@ -78,7 +78,7 @@ describe('package:version:promote / package:version:update', () => {
}
).jsonOutput.result;
expect(result).to.have.all.keys('id', 'success', 'errors');
expect(result.id.startsWith('04t')).to.be.true;
expect(result.id.slice(0, 3)).to.be.equal('04t');
expect(result.success).to.equal(true);
expect(result.errors).to.deep.equal([]);
});
Expand Down

0 comments on commit 1255c1c

Please sign in to comment.