Increase coverage: check for non-int with chown/fchown

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2018-11-29 19:14:43 -05:00 committed by David Humphrey
parent 43d2632069
commit cc6e3f7edf
1 changed files with 56 additions and 0 deletions

View File

@ -27,6 +27,62 @@ describe('fs.chown, fs.fchown', function() {
}); });
}); });
it('fchown should expect an interger value for uid', function(done) {
var fs = util.fs();
fs.open('/file', 'w', function(err, fd) {
if(err) throw err;
fs.fchown(fd, '1001', 1001, function(err) {
expect(err).to.exist;
expect(err.code).to.equal('EINVAL');
done();
});
});
});
it('chown should expect an interger value for uid', function(done) {
var fs = util.fs();
fs.writeFile('/file', 'w', function(err) {
if(err) throw err;
fs.chown('/file', '1001', 1001, function(err) {
expect(err).to.exist;
expect(err.code).to.equal('EINVAL');
done();
});
});
});
it('fchown should expect an interger value for gid', function(done) {
var fs = util.fs();
fs.open('/file', 'w', function(err, fd) {
if(err) throw err;
fs.fchown(fd, 1001, '1001', function(err) {
expect(err).to.exist;
expect(err.code).to.equal('EINVAL');
done();
});
});
});
it('chown should expect an interger value for gid', function(done) {
var fs = util.fs();
fs.writeFile('/file', 'w', function(err) {
if(err) throw err;
fs.chown('/file', 1001, '1001', function(err) {
expect(err).to.exist;
expect(err.code).to.equal('EINVAL');
done();
});
});
});
it('should allow updating gid and uid for a file', function(done) { it('should allow updating gid and uid for a file', function(done) {
var fs = util.fs(); var fs = util.fs();