Skip to content

Commit

Permalink
fix(tests): stub system class for command checkRoot
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vikaspotluri123 authored and acburdine committed Jul 13, 2018
1 parent 1357cc6 commit ba18452
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ class Command {
ui.log(`Unable to use "${dir}" (error ${err}). Please fix the issue and try again.`, 'red', true);
process.exit(1);
}
/* istanbul ignore next */
// In order to keep the rest of the function from running, chdir / exit is stubbed to
// throw an error in the tests so this line is technically unreachable. Since it's only
// a debug statement, we're not going to worry about it

debug('Finished updating directory');
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/command-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@ describe('Unit: Command', function () {
}
const Command = proxyquire(modulePath, {
'./utils/check-root-user': checkRootUserStub,
'./ui': ShortCircuit
'./system': ShortCircuit
});

const TestCommand = class extends Command {};
TestCommand.global = true;
TestCommand.allowRoot = true;

try {
TestCommand._run('test', {});
TestCommand._run('test', {dir: '.'});
} catch (e) {
expect(e).to.exist;
expect(e.message).to.equal('you shall not pass');
Expand Down

0 comments on commit ba18452

Please sign in to comment.