Skip to content

Commit 50cf4e5

Browse files
committed
test: fix moar UTs
1 parent ec9da42 commit 50cf4e5

File tree

9 files changed

+47
-89
lines changed

9 files changed

+47
-89
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"bugs": "https://github.com/forcedotcom/cli/issues",
88
"dependencies": {
99
"@oclif/core": "^1.7.0",
10-
"@salesforce/command": "^5.1.0",
10+
"@salesforce/command": "^5.1.3",
1111
"@salesforce/core": "^3.19.0",
1212
"@salesforce/kit": "^1.5.17",
1313
"open": "8.4.0",

src/commands/force/org/clone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class OrgCloneCommand extends SfdxCommand {
8888

8989
if (results?.sandboxRes?.authUserName) {
9090
if (this.flags.setalias) {
91-
const globalInfo = await GlobalInfo.create();
91+
const globalInfo = await GlobalInfo.getInstance();
9292
globalInfo.aliases.set(this.flags.setalias, results.sandboxRes.authUserName);
9393
const result = globalInfo.aliases.getAll();
9494
this.logger.debug('Set Alias: %s result: %s', this.flags.setalias, result);

src/commands/force/org/open.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ export class OrgOpenCommand extends SfdxCommand {
8080
const domain = `https://${/https?:\/\/([^.]*)/.exec(url)[1]}.lightning.force.com`;
8181
const timeout = new Duration(new Env().getNumber('SFDX_DOMAIN_RETRY', 240), Duration.Unit.SECONDS);
8282
this.logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
83-
throw new SfError(
84-
messages.getMessage('domainTimeoutError', [messages.getMessage('domainTimeoutError')]),
85-
'domainTimeoutError',
86-
['noOrgsFoundAction']
87-
);
83+
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
8884
}
8985
throw SfError.wrap(err);
9086
}

test/commands/force/org/clone.test.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
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 { Org, Aliases, Config, ConfigAggregator, Lifecycle, SandboxEvents } from '@salesforce/core';
7+
import { Org, Lifecycle, GlobalInfo, SandboxEvents, SfdxConfigAggregator, SfdxPropertyKeys } from '@salesforce/core';
88
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
99
import * as sinon from 'sinon';
10-
import { expect, IConfig } from '@salesforce/command/lib/test';
10+
import { expect } from '@salesforce/command/lib/test';
11+
import { Config } from '@oclif/core';
1112
import { UX } from '@salesforce/command';
1213
import { OrgCloneCommand } from '../../../../src/commands/force/org/clone';
1314

@@ -54,14 +55,14 @@ describe('org:clone', () => {
5455
retries: 0,
5556
waitingOnAuth: false,
5657
};
57-
const oclifConfigStub = fromStub(stubInterface<IConfig.IConfig>(sandbox));
58+
const oclifConfigStub = fromStub(stubInterface<Config>(sandbox));
5859

5960
// stubs
6061
let uxTableStub: sinon.SinonStub;
6162
let uxStyledHeaderStub: sinon.SinonStub;
6263
let uxLogStub: sinon.SinonStub;
6364
let cmd: TestOrgCloneCommand;
64-
let aliasSetStub: sinon.SinonStub;
65+
let aliasSetStub: sinon.SinonSpy;
6566
let configSetStub: sinon.SinonStub;
6667
let configWriteStub: sinon.SinonStub;
6768
let onStub: sinon.SinonStub;
@@ -77,7 +78,7 @@ describe('org:clone', () => {
7778
public setOrg(org: Org) {
7879
this.org = org;
7980
}
80-
public setConfigAggregator(configAggregator: ConfigAggregator) {
81+
public setConfigAggregator(configAggregator: SfdxConfigAggregator) {
8182
this.configAggregator = configAggregator;
8283
}
8384
}
@@ -104,7 +105,7 @@ describe('org:clone', () => {
104105
write: configWriteStub,
105106
}),
106107
};
107-
configAggregatorStub = fromStub(stubInterface<ConfigAggregator>(sandbox, configAggregatorStubOptions));
108+
configAggregatorStub = fromStub(stubInterface<SfdxConfigAggregator>(sandbox, configAggregatorStubOptions));
108109
cmd.setConfigAggregator(configAggregatorStub);
109110
});
110111
if (!fails) {
@@ -122,7 +123,15 @@ describe('org:clone', () => {
122123
stubMethod(sandbox, Lifecycle, 'getInstance').returns({
123124
on: onStub,
124125
});
125-
aliasSetStub = stubMethod(sandbox, Aliases.prototype, 'set').returns(sandboxalias);
126+
aliasSetStub = sinon.spy();
127+
stubMethod(sandbox, GlobalInfo, 'getInstance').returns({
128+
aliases: {
129+
set: aliasSetStub,
130+
getAll: () => ({
131+
sanboxname: sandboxalias,
132+
}),
133+
},
134+
});
126135
uxTableStub = stubMethod(sandbox, UX.prototype, 'table');
127136
uxLogStub = stubMethod(sandbox, UX.prototype, 'log');
128137
uxStyledHeaderStub = stubMethod(sandbox, UX.prototype, 'styledHeader');
@@ -201,7 +210,7 @@ describe('org:clone', () => {
201210
expect(aliasSetStub.callCount).to.be.equal(1);
202211
expect(aliasSetStub.firstCall.args[0]).to.be.equal(sandboxalias);
203212
expect(aliasSetStub.firstCall.args[1]).to.be.equal(authUserName);
204-
expect(configSetStub.firstCall.args[0]).to.be.equal(Config.DEFAULT_USERNAME);
213+
expect(configSetStub.firstCall.args[0]).to.be.equal(SfdxPropertyKeys.DEFAULT_USERNAME);
205214
expect(configSetStub.firstCall.args[1]).to.be.equal(authUserName);
206215
expect(onStub.firstCall.firstArg).to.be.equal(SandboxEvents.EVENT_ASYNC_RESULT);
207216
expect(onStub.secondCall.firstArg).to.be.equal(SandboxEvents.EVENT_STATUS);

test/commands/force/org/delete.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import { Messages, Org, SfProject } from '@salesforce/core';
88
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
99
import * as sinon from 'sinon';
10-
import { expect, Config as IConfig } from '@salesforce/command/lib/test';
10+
import { expect } from '@salesforce/command/lib/test';
11+
import { Config } from '@oclif/core';
1112
import { UX } from '@salesforce/command';
1213
import { Delete } from '../../../../src/commands/force/org/delete';
1314

@@ -18,7 +19,7 @@ describe('org:delete', () => {
1819
const sandbox = sinon.createSandbox();
1920
const username = '[email protected]';
2021
const orgId = '00D54000000KDltEAG';
21-
const oclifConfigStub = fromStub(stubInterface<IConfig>(sandbox));
22+
const oclifConfigStub = fromStub(stubInterface<Config>(sandbox));
2223

2324
// stubs
2425
let resolveProjectConfigStub: sinon.SinonStub;

test/commands/force/org/display.test.ts

Lines changed: 1 addition & 6 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 { expect, test } from '@salesforce/command/lib/test';
8-
import { Aliases, AuthInfo, Connection, Org } from '@salesforce/core';
8+
import { AuthInfo, Connection, Org } from '@salesforce/core';
99
import * as sinon from 'sinon';
1010
import { stubMethod, stubInterface, StubbedType } from '@salesforce/ts-sinon';
1111
import * as utils from '../../../../src/shared/utils';
@@ -48,11 +48,6 @@ describe('org:display', () => {
4848
const sandbox = sinon.createSandbox();
4949

5050
beforeEach(async function () {
51-
stubMethod(sandbox, Aliases, 'fetch')
52-
.withArgs('nonscratchalias')
53-
.resolves('[email protected]')
54-
.withArgs('scratchAlias')
55-
.resolves('[email protected]');
5651
stubMethod(sandbox, utils, 'getAliasByUsername')
5752
.withArgs('[email protected]')
5853
.resolves('nonscratchalias')

test/commands/force/org/list.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ import { OrgListUtil } from '../../../../src/shared/orgListUtil';
2121
describe('org_list', () => {
2222
const sandbox = sinon.createSandbox();
2323
beforeEach(async () => {
24-
stubMethod(sandbox, AuthInfo, 'listAllAuthFiles');
24+
stubMethod(sandbox, AuthInfo, 'listAllAuthorizations').resolves([
25+
'Jimi Hendrix',
26+
'SRV',
27+
'shenderson',
28+
'SRV',
29+
30+
]);
2531
});
2632
afterEach(() => {
2733
sandbox.restore();

test/commands/force/org/status.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
} from '@salesforce/core';
1717
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
1818
import * as sinon from 'sinon';
19-
import { expect, Config as IConfig } from '@salesforce/command/lib/test';
19+
import { expect } from '@salesforce/command/lib/test';
20+
import { Config } from '@oclif/core';
2021
import { UX } from '@salesforce/command';
2122
import { OrgStatusCommand } from '../../../../src/commands/force/org/status';
2223

@@ -51,7 +52,7 @@ describe('org:status', () => {
5152
loginUrl: 'https://my-login.com',
5253
},
5354
};
54-
const oclifConfigStub = fromStub(stubInterface<IConfig>(sandbox));
55+
const oclifConfigStub = fromStub(stubInterface<Config>(sandbox));
5556

5657
// stubs
5758
let uxTableStub: sinon.SinonStub;

yarn.lock

Lines changed: 13 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,13 @@
719719
version "1.18.3"
720720
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.18.3.tgz#ddfc144fdab66b1658c2f1b3478fa7fbfd317e79"
721721
integrity sha512-sBpko86IrTscc39EvHUhL+c++81BVTsIZ3ETu/vG+cCdi0N6vb2DoahR67A9FI2CGnxRRHjnTfa3m6LulwNATA==
722+
dependencies:
723+
"@oclif/errors" "^1.3.5"
724+
"@oclif/parser" "^3.8.0"
725+
debug "^4.1.1"
726+
globby "^11.0.1"
727+
is-wsl "^2.1.1"
728+
tslib "^2.3.1"
722729

723730
"@oclif/core@^1.0.8", "@oclif/core@^1.2.1", "@oclif/core@^1.3.4", "@oclif/core@^1.3.6", "@oclif/core@^1.6.4", "@oclif/core@^1.7.0":
724731
version "1.8.1"
@@ -755,40 +762,6 @@
755762
widest-line "^3.1.0"
756763
wrap-ansi "^7.0.0"
757764

758-
"@oclif/core@^1.3.1":
759-
version "1.9.0"
760-
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-1.9.0.tgz#bb2a7820a9176f28921f449c0f577d39c15e74d0"
761-
integrity sha512-duvlaRQf4JM+mKuwwos1DNa/Q9x6tnF3khV5RU0fy5hhETF7THlTmxioKlIvKMyQDVpySqtZXZ0OKHeCi2EWuQ==
762-
dependencies:
763-
"@oclif/linewrap" "^1.0.0"
764-
"@oclif/screen" "^3.0.2"
765-
ansi-escapes "^4.3.2"
766-
ansi-styles "^4.3.0"
767-
cardinal "^2.1.1"
768-
chalk "^4.1.2"
769-
clean-stack "^3.0.1"
770-
cli-progress "^3.10.0"
771-
debug "^4.3.4"
772-
ejs "^3.1.6"
773-
fs-extra "^9.1.0"
774-
get-package-type "^0.1.0"
775-
globby "^11.1.0"
776-
hyperlinker "^1.0.0"
777-
indent-string "^4.0.0"
778-
is-wsl "^2.2.0"
779-
js-yaml "^3.14.1"
780-
natural-orderby "^2.0.3"
781-
object-treeify "^1.1.33"
782-
password-prompt "^1.1.2"
783-
semver "^7.3.7"
784-
string-width "^4.2.3"
785-
strip-ansi "^6.0.1"
786-
supports-color "^8.1.1"
787-
supports-hyperlinks "^2.2.0"
788-
tslib "^2.3.1"
789-
widest-line "^3.1.0"
790-
wrap-ansi "^7.0.0"
791-
792765
"@oclif/dev-cli@^1":
793766
version "1.26.10"
794767
resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.26.10.tgz#d8df3a79009b68552f5e7f249d1d19ca52278382"
@@ -950,14 +923,6 @@
950923
dependencies:
951924
fancy-test "^1.4.10"
952925

953-
"@oclif/test@^2.1.0":
954-
version "2.1.0"
955-
resolved "https://registry.yarnpkg.com/@oclif/test/-/test-2.1.0.tgz#e5a0ba619c890770782e48c82d18f5921e2d2b9f"
956-
integrity sha512-o+JTv3k28aMUxywJUlJY1/DORLqumoZFRII492phOmtXM16rD6Luy3z1qinT4BvEtPj2BzOPd2whr/VdYszaYw==
957-
dependencies:
958-
"@oclif/core" "^1.3.1"
959-
fancy-test "^2.0.0"
960-
961926
"@octokit/auth-token@^2.4.4":
962927
version "2.5.0"
963928
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36"
@@ -1101,15 +1066,14 @@
11011066
chalk "^2.4.2"
11021067
cli-ux "^4.9.3"
11031068

1104-
"@salesforce/command@^5.1.0":
1105-
version "5.1.2"
1106-
resolved "https://registry.yarnpkg.com/@salesforce/command/-/command-5.1.2.tgz#934fa36679d8160512c4402705d0b8947a8b9d47"
1107-
integrity sha512-WbZlR1v/DYkO9Px5nBEexNrRK+aV9apC4rywyW92FTGrrNL9k6vjrf38JI18UuKuePFXzkQHUaz1/f99sC1bWA==
1069+
"@salesforce/command@^5.1.3":
1070+
version "5.1.3"
1071+
resolved "https://registry.yarnpkg.com/@salesforce/command/-/command-5.1.3.tgz#a55e9b8e746a5a68322f59a637f920470da6b51f"
1072+
integrity sha512-spVCcHh/SYM9L5oI52z+VSEOsAXgDxj6GTlEvkm+KPctsIUhtxS1xKzjeeVCuUmRmvfq5LgwtjcgTSIqkeoL9w==
11081073
dependencies:
11091074
"@oclif/core" "^1.7.0"
11101075
"@oclif/plugin-help" "^5.1.11"
1111-
"@oclif/test" "^2.1.0"
1112-
"@salesforce/core" "^3.15.3"
1076+
"@salesforce/core" "^3.19.0"
11131077
"@salesforce/kit" "^1.5.34"
11141078
"@salesforce/ts-types" "^1.5.20"
11151079
chalk "^2.4.2"
@@ -1138,7 +1102,7 @@
11381102
semver "^7.3.5"
11391103
ts-retry-promise "^0.6.0"
11401104

1141-
"@salesforce/core@^3.15.3", "@salesforce/core@^3.19.0":
1105+
"@salesforce/core@^3.19.0":
11421106
version "3.19.0"
11431107
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.19.0.tgz#e238b07190623dc4e1ca1888c1185f5bfa2d383e"
11441108
integrity sha512-64bz7cvfEkJz1JCMlf3W1CaWShoaINzfkrT6BQxtb5AdjZm5rs8Lmg3q6hie4hhWo3VVSvPOdnWEPpMJCdJ4/w==
@@ -3529,20 +3493,6 @@ fancy-test@^1.4.10:
35293493
nock "^13.0.0"
35303494
stdout-stderr "^0.1.9"
35313495

3532-
fancy-test@^2.0.0:
3533-
version "2.0.0"
3534-
resolved "https://registry.yarnpkg.com/fancy-test/-/fancy-test-2.0.0.tgz#f1477ae4190820318816914aabe273c0a0dbd597"
3535-
integrity sha512-SFb2D/VX9SV+wNYXO1IIh1wyxUC1GS0mYCFJOWD1ia7MPj9yE2G8jaPkw4t/pg0Sj7/YJP56OzMY4nAuJSOugQ==
3536-
dependencies:
3537-
"@types/chai" "*"
3538-
"@types/lodash" "*"
3539-
"@types/node" "*"
3540-
"@types/sinon" "*"
3541-
lodash "^4.17.13"
3542-
mock-stdin "^1.0.0"
3543-
nock "^13.0.0"
3544-
stdout-stderr "^0.1.9"
3545-
35463496
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
35473497
version "3.1.3"
35483498
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"

0 commit comments

Comments
 (0)