shell: add promises test

This commit is contained in:
Girish Ramakrishnan
2021-06-03 19:32:29 -07:00
parent a0c4ef9d0f
commit 4937cbbc0b

View File

@@ -4,8 +4,9 @@
'use strict';
var expect = require('expect.js'),
const expect = require('expect.js'),
path = require('path'),
safe = require('safetydance'),
shell = require('../shell.js');
describe('shell', function () {
@@ -46,13 +47,21 @@ describe('shell', function () {
});
});
it('can run valid program (promises)', async function () {
let RELOAD_NGINX_CMD = path.join(__dirname, '../src/scripts/restartservice.sh');
await safe(shell.promises.sudo('test', [ RELOAD_NGINX_CMD, 'nginx' ], {}));
});
it('execSync a valid shell program', function (done) {
shell.exec('test', 'ls -l | wc -c', function (error) {
console.log(error);
done(error);
});
});
it('execSync a valid shell program (promises)', async function () {
await shell.promises.exec('test', 'ls -l | wc -c');
});
it('execSync throws for invalid program', function (done) {
shell.exec('test', 'cannotexist', function (error) {
expect(error).to.be.ok();