Skip to content

Commit cf2425f

Browse files
committed
fix: fix tests
1 parent bc02c9a commit cf2425f

File tree

4 files changed

+18
-36
lines changed

4 files changed

+18
-36
lines changed

test/commands/package/packagePushUpgradeAbort.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { Config } from '@oclif/core';
9-
import { TestContext, MockTestOrgData, sinon } from '@salesforce/core/testSetup';
9+
import { TestContext, MockTestOrgData } from '@salesforce/core/testSetup';
1010
import { expect } from 'chai';
1111
import { PackagePushUpgrade } from '@salesforce/packaging';
1212
import { SfCommand } from '@salesforce/sf-plugins-core';
@@ -45,7 +45,7 @@ describe('PackagePushUpgradeAbortCommand', () => {
4545
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4646
expect(logStub.callCount).to.equal(1);
4747
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
48-
expect(logStub.args[0]).to.deep.equal([`Scheduled push upgrade ID ${pushRequestId} was canceled.`]);
48+
expect(logStub.args[0]).to.deep.equal([`Scheduled push upgrade ID [${pushRequestId}] was cancelled.`]);
4949
});
5050

5151
it('should throw an error if push-request-id is missing', async () => {

test/commands/package/packagePushUpgradeList.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ describe('package:pushupgrade:list - tests', () => {
6161
});
6262

6363
it('should list the push upgrade requests', async () => {
64-
const cmd = new PackagePushRequestListCommand(['-v', testOrg.username], config);
64+
const packageId = 'dummyPackageId';
65+
const cmd = new PackagePushRequestListCommand(['-v', testOrg.username, '--package', packageId], config);
6566
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
6667
listStub.resolves(pushUpgradeListSuccess);
6768
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
@@ -83,7 +84,8 @@ describe('package:pushupgrade:list - tests', () => {
8384
});
8485

8586
it('should handle no results found', async () => {
86-
const cmd = new PackagePushRequestListCommand(['-v', testOrg.username], config);
87+
const packageId = 'dummyPackageId';
88+
const cmd = new PackagePushRequestListCommand(['-v', testOrg.username, '--package', packageId], config);
8789
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
8890
listStub.resolves([]);
8991

@@ -95,7 +97,7 @@ describe('package:pushupgrade:list - tests', () => {
9597

9698
it('should filter by is-migration flag', async () => {
9799
const packageId = '033XXXXXXXXXXXXXXX';
98-
const cmdArgs = ['--target-dev-hub', testOrg.username, '--package', packageId, '--is-migration'];
100+
const cmdArgs = ['--target-dev-hub', testOrg.username, '--package', packageId, '--show-push-migrations-only'];
99101
const cmd = new PackagePushRequestListCommand(cmdArgs, config);
100102

101103
listStub.resolves(pushUpgradeListSuccess);

test/commands/package/packagePushUpgradeReport.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import { Config } from '@oclif/core';
8-
import { TestContext, sinon } from '@salesforce/core/testSetup';
8+
import { TestContext } from '@salesforce/core/testSetup';
99
import { expect } from 'chai';
1010
import {
1111
PackagePushUpgrade,
@@ -103,7 +103,15 @@ describe('package:pushupgrade:report - tests', () => {
103103
const cmd = new PackagePushUpgradeReportCommand(['-i', '0DVxx0000004EXTGA2', '-v', '[email protected]'], config);
104104
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
105105
reportStub.rejects(new Error('Report error'));
106-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
107-
await expect(cmd.run()).to.be.rejectedWith('Report error');
106+
try {
107+
await cmd.run();
108+
// If cmd.run() resolves, this line will be reached, and the test should fail.
109+
expect.fail('Expected cmd.run() to reject, but it resolved.');
110+
} catch (err) {
111+
// Assert that an error was indeed thrown
112+
expect(err).to.be.an.instanceof(Error);
113+
// Assert the error message matches
114+
expect((err as Error).message).to.equal('Report error');
115+
}
108116
});
109117
});

test/commands/package/packagePushUpgradeSchedule.test.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import * as fs from 'node:fs/promises';
87
import { Config } from '@oclif/core';
98
import { TestContext, MockTestOrgData } from '@salesforce/core/testSetup';
109
import * as sinon from 'sinon';
@@ -33,39 +32,12 @@ describe('package:pushupgrade:schedule - tests', () => {
3332
sfCommandStubs = stubSfCommandUx($$.SANDBOX);
3433
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
3534
scheduleStub = $$.SANDBOX.stub(PackagePushUpgrade, 'schedule');
36-
$$.SANDBOX.stub(fs, 'readFile').resolves('00Dxx0000001gEREAY\n00Dxx0000001gFAEA0');
3735
});
3836

3937
afterEach(() => {
4038
$$.restore();
4139
});
4240

43-
it('should schedule the push upgrade with file', async () => {
44-
const cmdArgsFile = [
45-
'-p',
46-
'04tXXXXXXXXXXXXXXX',
47-
'-v',
48-
testOrg.username,
49-
'--start-time',
50-
'2023-01-01T00:00:00Z',
51-
'--org-list-file',
52-
'valid-orgs.csv',
53-
];
54-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
55-
const cmd = new PackagePushScheduleCommand(cmdArgsFile, config);
56-
57-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
58-
scheduleStub.resolves(pushReq);
59-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
60-
const result = await cmd.run();
61-
expect(result).to.deep.equal(pushReq);
62-
63-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
64-
expect(sfCommandStubs.log.calledOnce).to.be.true;
65-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
66-
expect(scheduleStub.calledOnce).to.be.true;
67-
});
68-
6941
it('should schedule the push upgrade with org input', async () => {
7042
const cmdArgsOrg = [
7143
'-p',

0 commit comments

Comments
 (0)