Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
humphd opened this issue Dec 16, 2018 · 1 comment
Open

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

humphd opened this issue Dec 16, 2018 · 1 comment
Labels
good first bug test-coverage Increase Test Coverage

Comments

@humphd
Copy link
Contributor

humphd commented Dec 16, 2018

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 humphd added good first bug test-coverage Increase Test Coverage labels Dec 16, 2018
@humphd
Copy link
Contributor Author

humphd commented Dec 16, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first bug test-coverage Increase Test Coverage
Projects
None yet
Development

No branches or pull requests

1 participant