From cc6e3f7edf5ae7d6106c6c3b22b0e4a44bdb3a53 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Thu, 29 Nov 2018 19:14:43 -0500 Subject: [PATCH] Increase coverage: check for non-int with chown/fchown --- tests/spec/fs.chown.spec.js | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/spec/fs.chown.spec.js b/tests/spec/fs.chown.spec.js index f89c2b6..515c9cb 100644 --- a/tests/spec/fs.chown.spec.js +++ b/tests/spec/fs.chown.spec.js @@ -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) { var fs = util.fs();