test: fix a TODO and remove obsolete TODOs
This removes outdated TODOs and adds a test for invalid input in `fs.copyFile` and solves a TODO by doing so. PR-URL: https://github.com/nodejs/node/pull/20319 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
29cddb40b2
commit
541d2192cf
@ -281,9 +281,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
|
|||||||
// http://a@b@c/ => user:a@b host:c
|
// http://a@b@c/ => user:a@b host:c
|
||||||
// http://a@b?@c => user:a host:b path:/?@c
|
// http://a@b?@c => user:a host:b path:/?@c
|
||||||
|
|
||||||
// v0.12 TODO(isaacs): This is not quite how Chrome does things.
|
|
||||||
// Review our test case against browsers more comprehensively.
|
|
||||||
|
|
||||||
var hostEnd = -1;
|
var hostEnd = -1;
|
||||||
var atSign = -1;
|
var atSign = -1;
|
||||||
var nonHost = -1;
|
var nonHost = -1;
|
||||||
|
@ -45,7 +45,6 @@ if (cluster.isMaster) {
|
|||||||
http.createServer(common.mustCall((req, res) => {
|
http.createServer(common.mustCall((req, res) => {
|
||||||
assert.strictEqual(req.connection.remoteAddress, undefined);
|
assert.strictEqual(req.connection.remoteAddress, undefined);
|
||||||
assert.strictEqual(req.connection.localAddress, undefined);
|
assert.strictEqual(req.connection.localAddress, undefined);
|
||||||
// TODO common.PIPE?
|
|
||||||
|
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end('OK');
|
res.end('OK');
|
||||||
|
@ -636,22 +636,21 @@ if (!common.isAIX) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copyFile with invalid flags
|
// Check copyFile with invalid flags.
|
||||||
{
|
{
|
||||||
const validateError = (err) => {
|
const validateError = {
|
||||||
assert.strictEqual(err.message,
|
// TODO: Make sure the error message always also contains the src.
|
||||||
'EINVAL: invalid argument, copyfile ' +
|
message: `EINVAL: invalid argument, copyfile -> '${nonexistentFile}'`,
|
||||||
`'${existingFile}' -> '${nonexistentFile}'`);
|
errno: uv.UV_EINVAL,
|
||||||
assert.strictEqual(err.errno, uv.UV_EINVAL);
|
code: 'EINVAL',
|
||||||
assert.strictEqual(err.code, 'EINVAL');
|
syscall: 'copyfile'
|
||||||
assert.strictEqual(err.syscall, 'copyfile');
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(joyeecheung): test fs.copyFile() when uv_fs_copyfile does not
|
fs.copyFile(existingFile, nonexistentFile, -1,
|
||||||
// keep the loop open when the flags are invalid.
|
common.expectsError(validateError));
|
||||||
// See https://github.com/libuv/libuv/pull/1747
|
|
||||||
|
|
||||||
|
validateError.message = 'EINVAL: invalid argument, copyfile ' +
|
||||||
|
`'${existingFile}' -> '${nonexistentFile}'`;
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => fs.copyFileSync(existingFile, nonexistentFile, -1),
|
() => fs.copyFileSync(existingFile, nonexistentFile, -1),
|
||||||
validateError
|
validateError
|
||||||
|
@ -419,8 +419,6 @@ notUtilIsDeepStrict([1, , , 3], [1, , , 3, , , ]);
|
|||||||
const err3 = new TypeError('foo1');
|
const err3 = new TypeError('foo1');
|
||||||
notUtilIsDeepStrict(err1, err2, assert.AssertionError);
|
notUtilIsDeepStrict(err1, err2, assert.AssertionError);
|
||||||
notUtilIsDeepStrict(err1, err3, assert.AssertionError);
|
notUtilIsDeepStrict(err1, err3, assert.AssertionError);
|
||||||
// TODO: evaluate if this should throw or not. The same applies for RegExp
|
|
||||||
// Date and any object that has the same keys but not the same prototype.
|
|
||||||
notUtilIsDeepStrict(err1, {}, assert.AssertionError);
|
notUtilIsDeepStrict(err1, {}, assert.AssertionError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user