cleaned up code. replaced all callbacks with promises in new test.
This commit is contained in:
parent
871c0fe88c
commit
71a6f514fc
|
@ -18,7 +18,7 @@
|
||||||
],
|
],
|
||||||
"linebreak-style": [
|
"linebreak-style": [
|
||||||
"error",
|
"error",
|
||||||
"unix"
|
"windows"
|
||||||
],
|
],
|
||||||
"quotes": [
|
"quotes": [
|
||||||
"error",
|
"error",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -69,44 +69,21 @@ describe('fs.promises.chown', function(){
|
||||||
afterEach(util.setup);
|
afterEach(util.setup);
|
||||||
|
|
||||||
it('should be a function', function(){
|
it('should be a function', function(){
|
||||||
var fs= util.fs();
|
var fsPromises = util.fs().promises;
|
||||||
expect(fs.promises.chown).to.be.a('function');
|
expect(fsPromises.chown).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow updating uid and gid for a file', function(done) {
|
it('should allow updating uid and gid for a file', function() {
|
||||||
var fs = util.fs();
|
var fsPromises = util.fs().promises;
|
||||||
|
|
||||||
fs.open('/file', 'w', function(err, fd) {
|
return fsPromises.writeFile('/file', 'data')
|
||||||
if(err) throw err;
|
.then(() =>
|
||||||
|
fsPromises.chown('/file', 500, 500))
|
||||||
fs.fchown(fd, 1001, 1001, function(err) {
|
.then(() =>
|
||||||
if(err) throw err;
|
fsPromises.stat('/file'))
|
||||||
|
.then((stats) =>{
|
||||||
fs.fstat(fd, function(err, stats){
|
expect(stats.uid).to.equal(500);
|
||||||
if(err) throw err;
|
expect(stats.gid).to.equal(500);
|
||||||
|
});
|
||||||
expect(stats.uid).to.equal(1001);
|
|
||||||
|
|
||||||
fs.close(fd, function(){
|
|
||||||
if(err) throw err;
|
|
||||||
|
|
||||||
return fs.promises.chown('/file', 500, 500)
|
|
||||||
.then(()=>{
|
|
||||||
fs.stat('/file', function(err, stats){
|
|
||||||
if(err) throw err;
|
|
||||||
|
|
||||||
expect(stats.uid).to.equal(500);
|
|
||||||
expect(stats.gid).to.equal(500);
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((err)=>{
|
|
||||||
throw(err)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue