filer icon indicating copy to clipboard operation
filer copied to clipboard

Add test for fs.link() with newpath pointing to an existing file

Open humphd opened this issue 6 years ago • 1 comments

https://codecov.io/gh/filerjs/filer/src/master/src/filesystem/implementation.js#L954 is a branch we don't test. To hit it, I think we need:

  • add a test to fs.link.spec.js
  • create two files
  • try to fs.link() one to the other (i.e., newpath exists)
  • expect an EEXISTS error to be returned

Somewhat similar to this test, but first create a file and use that instead of /mydirlink

  it('should not allow links to a directory', function(done) {
    var fs = util.fs();

    fs.mkdir('/mydir', function(error) {
      if(error) throw error;

      fs.link('/mydir', '/mydirlink', function(error) {
        expect(error).to.exist;
        expect(error.code).to.equal('EPERM');
        done();
      });
    });
});

humphd avatar Dec 16 '18 04:12 humphd

Also, add another test for the same case using symlink instead of link, and try to hit https://codecov.io/gh/filerjs/filer/src/master/src/filesystem/implementation.js#L1147.

humphd avatar Dec 16 '18 04:12 humphd