shell: make shell.sudo promise based and waitable
This commit is contained in:
+6
-15
@@ -46,24 +46,15 @@ describe('shell', function () {
|
||||
});
|
||||
|
||||
describe('sudo', function () {
|
||||
it('cannot sudo invalid program', function (done) {
|
||||
shell.sudo([ 'randomprogram' ], {}, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
done();
|
||||
});
|
||||
it('cannot sudo invalid program', async function () {
|
||||
const [error] = await safe(shell.sudo([ 'randomprogram' ], {}));
|
||||
expect(error).to.be.ok();
|
||||
});
|
||||
|
||||
it('can sudo valid program', function (done) {
|
||||
it('can sudo valid program', async function () {
|
||||
const RELOAD_NGINX_CMD = path.join(__dirname, '../src/scripts/restartservice.sh');
|
||||
shell.sudo([ RELOAD_NGINX_CMD, 'nginx' ], {}, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can run valid program (promises)', async function () {
|
||||
const RELOAD_NGINX_CMD = path.join(__dirname, '../src/scripts/restartservice.sh');
|
||||
await safe(shell.promises.sudo([ RELOAD_NGINX_CMD, 'nginx' ], {}));
|
||||
const [error] = await safe(shell.sudo([ RELOAD_NGINX_CMD, 'nginx' ], {}));
|
||||
expect(error).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user