Skip to content

Add test for fs.open() with O_WRITE and the root directory as path / #622

Open
@humphd

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 the O_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

humphd commented on Dec 16, 2018

@humphd
ContributorAuthor

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

cdrani commented on Feb 27, 2019

@cdrani
Contributor

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

humphd commented on Mar 4, 2019

@humphd
ContributorAuthor

@cdrani no, you can skip the /tmp dir and use /.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Add test for fs.open() with O_WRITE and the root directory as path / · Issue #622 · filerjs/filer