Skip to content

Commit 20d4e84

Browse files
committed
chore: use commands instead of file read
1 parent 716f0d2 commit 20d4e84

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import * as fs from 'fs';
98
import * as path from 'path';
109
import { TestSession, execCmd } from '@salesforce/cli-plugins-testkit';
1110
import { expect } from 'chai';
@@ -100,11 +99,12 @@ describe('test sandbox status command', () => {
10099
}
101100
).jsonOutput.result;
102101
expect(orgStatusResult).to.be.ok;
103-
104-
const config = JSON.parse(
105-
fs.readFileSync(path.join(session.project.dir, '..', '.sfdx', 'sfdx-config.json'), 'utf8')
106-
) as Record<string, string>;
107-
expect(config.defaultusername).to.be.equal(`${username}.${sandboxName}`);
102+
const execOptions: shell.ExecOptions = {
103+
silent: true,
104+
};
105+
const result = shell.exec('sfdx config:get defaultusername --json', execOptions) as shell.ShellString;
106+
expect(result.code).to.equal(0);
107+
expect(result.stdout).to.contain(`"${username}.${sandboxName}"`);
108108
});
109109

110110
it('sandbox status command set alias', async () => {
@@ -115,18 +115,12 @@ describe('test sandbox status command', () => {
115115
}
116116
).jsonOutput.result;
117117
expect(orgStatusResult).to.be.ok;
118-
119-
const aliases = JSON.parse(
120-
fs.readFileSync(path.join(session.project.dir, '..', '.sfdx', 'alias.json'), 'utf8')
121-
) as {
122-
orgs: Record<string, string>;
118+
const execOptions: shell.ExecOptions = {
119+
silent: true,
123120
};
124-
125-
expect(aliases).to.deep.equal({
126-
orgs: {
127-
[`${sandboxName}`]: `${username}.${sandboxName}`,
128-
},
129-
});
121+
const result = shell.exec('sfdx alias:list --json', execOptions) as shell.ShellString;
122+
expect(result.code).to.equal(0);
123+
expect(result.stdout).to.contain(`"${sandboxName}"`);
130124
});
131125

132126
after(async () => {

0 commit comments

Comments
 (0)