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

test: increase test coverage for readfile with withFileTypes option #23557

Conversation

@christian-bromann
Copy link
Contributor

christian-bromann commented Oct 12, 2018

According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with withFileTypes
option.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
withFileTypes: true
}, common.mustCall((err) => {
assert.ok(err);
}));

This comment has been minimized.

Copy link
@BridgeAR

BridgeAR Oct 12, 2018

Member

As a suggestion:

To test the actual error it would be best to rewrite this to e.g.,:

fs.readdir(__filename, { withFileTypes: true }, common.expectsError({
  message: 'FOOBAR',
  name: 'ErrorName',
  ...
});

This comment has been minimized.

Copy link
@christian-bromann

christian-bromann Oct 12, 2018

Author Contributor

@BridgeAR the error is actually passed within the fs.readdir callback, how about:

fs.readdir(__filename, {
  withFileTypes: true
}, common.mustCall((err) => {
  assert.throws(
    () => { throw err; },
    {
      code: 'ENOTDIR',
      name: 'Error',
      message: `ENOTDIR: not a directory, scandir '${__filename}'`
    }
  );
}));

This comment has been minimized.

Copy link
@BridgeAR

BridgeAR Oct 17, 2018

Member

Right, sorry, I made a mistake when writing the example. I just updated it.

According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with withFileTypes
option.
@christian-bromann christian-bromann force-pushed the christian-bromann:test-coverage-readdir branch from e07d92b to e4151af Oct 15, 2018
@addaleax

This comment has been minimized.

@apapirovski

This comment has been minimized.

Copy link
Member

apapirovski commented Oct 18, 2018

@addaleax

This comment has been minimized.

Copy link
Member

addaleax commented Oct 21, 2018

Landed in 6c5e97f

Thanks for the contribution! 🎉

(If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.)

@addaleax addaleax closed this Oct 21, 2018
addaleax added a commit that referenced this pull request Oct 21, 2018
According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with
withFileTypes option.

PR-URL: #23557
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell added a commit that referenced this pull request Oct 21, 2018
According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with
withFileTypes option.

PR-URL: #23557
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins added a commit that referenced this pull request Nov 26, 2018
According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with
withFileTypes option.

PR-URL: #23557
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@codebytere codebytere mentioned this pull request Nov 27, 2018
rvagg added a commit that referenced this pull request Nov 28, 2018
According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with
withFileTypes option.

PR-URL: #23557
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins added a commit that referenced this pull request Nov 29, 2018
According to the test coverage report a test case was missings checking
if an error is passed into the callback for readdir calls with
withFileTypes option.

PR-URL: #23557
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@codebytere codebytere mentioned this pull request Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.