Add setName and exec test

This commit is contained in:
Joran Dirk Greef 2015-09-07 08:51:27 +02:00
parent 1698b73841
commit 36ab9581de

22
test.js Normal file
View file

@ -0,0 +1,22 @@
var sudo = require('./');
var exec = require('child_process').exec;
function cleanup() {
exec('sudo -k');
}
console.log('sudo.setName("Test")');
console.log('sudo.exec("echo hello")');
sudo.setName('Test');
sudo.exec('echo hello',
function(error, stdout, stderr) {
console.log('error: ' + error);
console.log('stdout: ' + JSON.stringify(stdout));
console.log('stderr: ' + JSON.stringify(stderr));
cleanup();
if (error) throw error;
if (stdout !== 'hello\n') throw new Error('stdout != "hello\n"');
if (stderr !== "") throw new Error('stderr != ""');
console.log('OK');
}
);