Skip to content

Commit

Permalink
feat(stack): add support for ubuntu 18
Browse files Browse the repository at this point in the history
closes #794
- update system-stack check to account for ubuntu 18
  • Loading branch information
acburdine committed Aug 27, 2018
1 parent 478277f commit 7d17adb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/commands/doctor/checks/system-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function systemStack(ctx, task) {
} else {
// TODO: refactor to use ctx.system.operatingSystem
promise = execa.shell('lsb_release -a').catch(
() => Promise.reject({message: 'Linux version is not Ubuntu 16'})
() => Promise.reject({message: 'Linux version is not Ubuntu 16 or 18'})
).then((result) => {
if (!result.stdout || !result.stdout.match(/Ubuntu 16/)) {
return Promise.reject({message: 'Linux version is not Ubuntu 16'});
if (!result.stdout || !result.stdout.match(/Ubuntu (?:16|18)/)) {
return Promise.reject({message: 'Linux version is not Ubuntu 16 or 18'});
}

return ctx.ui.listr([{
Expand Down
24 changes: 22 additions & 2 deletions test/unit/commands/doctor/checks/system-stack-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Unit: Doctor Checks > systemStack', function () {
expect(false, 'error should have been thrown').to.be.true;
}).catch((error) => {
expect(error).to.be.an.instanceof(errors.SystemError);
expect(error.message).to.equal('System stack checks failed with message: \'Linux version is not Ubuntu 16\'');
expect(error.message).to.equal('System stack checks failed with message: \'Linux version is not Ubuntu 16 or 18\'');
expect(execaStub.calledOnce).to.be.true;
expect(logStub.calledOnce).to.be.true;
expect(logStub.args[0][0]).to.match(/failed with message/);
Expand All @@ -110,7 +110,7 @@ describe('Unit: Doctor Checks > systemStack', function () {
expect(false, 'error should have been thrown').to.be.true;
}).catch((error) => {
expect(error).to.be.an.instanceof(errors.SystemError);
expect(error.message).to.equal('System stack checks failed with message: \'Linux version is not Ubuntu 16\'');
expect(error.message).to.equal('System stack checks failed with message: \'Linux version is not Ubuntu 16 or 18\'');
expect(execaStub.calledOnce).to.be.true;
expect(logStub.calledOnce).to.be.true;
expect(logStub.args[0][0]).to.match(/failed with message/);
Expand Down Expand Up @@ -218,4 +218,24 @@ describe('Unit: Doctor Checks > systemStack', function () {
expect(confirmStub.called).to.be.false;
});
});

it('resolves if all stack conditions are met (ubuntu 18)', function () {
const execaStub = sinon.stub(execa, 'shell');
const logStub = sinon.stub();
const confirmStub = sinon.stub().resolves(false);

execaStub.withArgs('lsb_release -a').resolves({stdout: 'Ubuntu 18'});
const listrStub = sinon.stub().resolves();

const ctx = {
ui: {log: logStub, confirm: confirmStub, listr: listrStub, allowPrompt: true},
system: {platform: {linux: true}}
};

return systemStack.task(ctx).then(() => {
expect(listrStub.calledOnce).to.be.true;
expect(logStub.called).to.be.false;
expect(confirmStub.called).to.be.false;
});
});
});

0 comments on commit 7d17adb

Please sign in to comment.