From 3bbabfcb4a76b63cc490491d7cf9fab76b5b1696 Mon Sep 17 00:00:00 2001 From: ThomasNolte Date: Tue, 16 Oct 2018 11:43:59 -0400 Subject: [PATCH] added tests for fs.promises.chown() closes #465 (#471) * added tests for fs.promises.chown() for check if function exists and updating gid/uid for a file * update to pass lint tests * cleaned up code. replaced all callbacks with promises in new test. * Revert "lint tests fix" This reverts commit 3c256124cf43389c5b05f7ac349e0de7a5b31ec9, reversing changes made to 71a6f514fc0dc159929ef7aa66060d0ee76e9965. * Revert "cleaned up code. replaced all callbacks with promises in new test." This reverts commit 71a6f514fc0dc159929ef7aa66060d0ee76e9965. * Made requested changes. --- tests/spec/fs.chown.spec.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/spec/fs.chown.spec.js b/tests/spec/fs.chown.spec.js index d6de220..f89c2b6 100644 --- a/tests/spec/fs.chown.spec.js +++ b/tests/spec/fs.chown.spec.js @@ -62,3 +62,27 @@ describe('fs.chown, fs.fchown', function() { }); }); }); + + +describe('fs.promises.chown', function(){ + beforeEach(util.setup); + afterEach(util.setup); + + it('should be a function', function(){ + var fsPromises = util.fs().promises; + expect(fsPromises.chown).to.be.a('function'); + }); + + it('should allow updating uid and gid for a file', function() { + var fsPromises = util.fs().promises; + return fsPromises.writeFile('/file', 'data') + .then(() => + fsPromises.chown('/file', 500, 500)) + .then(() => + fsPromises.stat('/file')) + .then((stats) =>{ + expect(stats.uid).to.equal(500); + expect(stats.gid).to.equal(500); + }); + }); +});