tentative: replaced remaining callbacks with promises. check error propagation correctness

This commit is contained in:
michael-overall 2018-09-26 00:21:43 -04:00
parent a1e73febc1
commit 5abefb6c6a
1 changed files with 66 additions and 74 deletions

View File

@ -162,33 +162,25 @@ describe('fs.rename', function() {
done();
}
}
fs.open('/myfile', 'w+', function(error, fd) {
if(error) throw error;
fs.close(fd, function(error) {
if(error) throw error;
fs.promises.rename('/myfile', '/myotherfile').then(
function(){
fs.stat('/myfile', function(error, result) {
expect(error).to.exist;
expect(result).not.to.exist;
//TODO: CHECK PROMISE ERRORS ARE PROPAGATED CORRECTLY (re-throw?)
Promise.all(
fs.promises.open('/myfile', 'w+')
.then((fd)=>fs.promises.close(fd)),
fs.promises.rename('/myfile', '/myotherfile'),
//TODO: for both stat() check expect() vs assert()
fs.promises.stat('/myfile')
.then( (result)=> expect(result).not.to.exist, (error) => expect(error).to.exist)
.finally(()=>{
complete1 = true;
maybeDone();
});
fs.stat('/myotherfile', function(error, result) {
expect(error).not.to.exist;
expect(result.nlinks).to.equal(1);
}),
fs.promises.stat('/myotherfile')
.then( (result) => expect(result.nlinks).to.equal(1), (error) => expect(error).not.to.exist)
.finally(()=>{
complete2 = true;
maybeDone();
});
},
function(error){throw error;}
})
);
});
});
//TODO: .catch() probably not necessary--we just want errors to percolate up...
});
});