Add test for fs.open() with O_WRITE and the root directory as path / #622
Open
Description
https://codecov.io/gh/filerjs/filer/src/master/src/filesystem/implementation.js#L568 is a branch we don't test. To hit it, I think we need:
- add at test to
fs.open.spec.js
- open a path
/
(the root directory) and pass the theO_WRITE
flag'w'
- expect an
EISDIR
error to be returned.
Very similar to this test, but with /
instead of /tmp
:
it('should return an error when flagged for write and the path is a directory', function(done) {
var fs = util.fs();
fs.mkdir('/tmp', function(error) {
if(error) throw error;
fs.open('/tmp', 'w', function(error, result) {
expect(error).to.exist;
expect(error.code).to.equal('EISDIR');
expect(result).not.to.exist;
done();
});
});
});
Activity
humphd commentedon Dec 16, 2018
Also add another test for this same case, only first create a symlink to
/
and follow the same procedure as above. This should get us into https://codecov.io/gh/filerjs/filer/src/master/src/filesystem/implementation.js#L636.cdrani commentedon Feb 27, 2019
I'm currently working on this and unsure about the second case with the symlink. Am I right in assuming that I should make
tmp
directory first, symlink it to/
, and then try to open/
with O_WRITE flag?humphd commentedon Mar 4, 2019
@cdrani no, you can skip the
/tmp
dir and use/
.