Skip to content

Commit ba18452

Browse files
vikaspotluri123acburdine
authored andcommitted
fix(tests): stub system class for command checkRoot
With 9786477 the order commands were run in was changed so the check wasn't properly run. By stubbing the system class instead of the ui class, we restore original behavior
1 parent 1357cc6 commit ba18452

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/command.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ class Command {
136136
ui.log(`Unable to use "${dir}" (error ${err}). Please fix the issue and try again.`, 'red', true);
137137
process.exit(1);
138138
}
139-
/* istanbul ignore next */
140-
// In order to keep the rest of the function from running, chdir / exit is stubbed to
141-
// throw an error in the tests so this line is technically unreachable. Since it's only
142-
// a debug statement, we're not going to worry about it
139+
143140
debug('Finished updating directory');
144141
}
145142

test/unit/command-spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ describe('Unit: Command', function () {
218218
}
219219
const Command = proxyquire(modulePath, {
220220
'./utils/check-root-user': checkRootUserStub,
221-
'./ui': ShortCircuit
221+
'./system': ShortCircuit
222222
});
223223

224224
const TestCommand = class extends Command {};
225225
TestCommand.global = true;
226226
TestCommand.allowRoot = true;
227227

228228
try {
229-
TestCommand._run('test', {});
229+
TestCommand._run('test', {dir: '.'});
230230
} catch (e) {
231231
expect(e).to.exist;
232232
expect(e.message).to.equal('you shall not pass');

0 commit comments

Comments
 (0)