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": [
|
||||
"error",
|
||||
"unix"
|
||||
"windows"
|
||||
],
|
||||
"quotes": [
|
||||
"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);
|
||||
|
||||
it('should be a function', function(){
|
||||
var fs= util.fs();
|
||||
expect(fs.promises.chown).to.be.a('function');
|
||||
var fsPromises = util.fs().promises;
|
||||
expect(fsPromises.chown).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should allow updating uid and gid for a file', function(done) {
|
||||
var fs = util.fs();
|
||||
it('should allow updating uid and gid for a file', function() {
|
||||
var fsPromises = util.fs().promises;
|
||||
|
||||
fs.open('/file', 'w', function(err, fd) {
|
||||
if(err) throw err;
|
||||
|
||||
fs.fchown(fd, 1001, 1001, function(err) {
|
||||
if(err) throw err;
|
||||
|
||||
fs.fstat(fd, function(err, stats){
|
||||
if(err) throw err;
|
||||
|
||||
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)
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue