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

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

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Oct 12, 2018
@addaleax addaleax added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Oct 12, 2018
withFileTypes: true
}, common.mustCall((err) => {
assert.ok(err);
}));
Copy link
Member

@BridgeAR BridgeAR Oct 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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',
  ...
});

Copy link
Contributor Author

@christian-bromann christian-bromann Oct 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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}'`
    }
  );
}));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@addaleax
Copy link
Member

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 16, 2018
@apapirovski
Copy link
Member

@addaleax
Copy link
Member

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 pushed 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 pushed 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 pushed 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 pushed 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 pushed 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
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants