Skip to content

Commit

Permalink
test: fix wrong error classes passed in as type
Browse files Browse the repository at this point in the history
PR-URL: #13686
Fixes: #13682
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
BridgeAR committed Jan 6, 2018
1 parent 22760f3 commit f26cabb
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 16 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-crypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ common.expectsError(
}, ''),
{
code: 'ERR_INVALID_OPT_VALUE',
type: Error,
type: TypeError,
message: 'The value "undefined" is invalid for option "padding"'
});

Expand All @@ -47,7 +47,7 @@ common.expectsError(
}, ''),
{
code: 'ERR_INVALID_OPT_VALUE',
type: Error,
type: TypeError,
message: 'The value "undefined" is invalid for option "saltLength"'
});

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-fs-timestamp-parsing-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const assert = require('assert');
},
{
code: 'ERR_INVALID_ARG_TYPE',
type: Error
type: TypeError
});
});

Expand All @@ -20,7 +20,7 @@ common.expectsError(
},
{
code: 'ERR_INVALID_ARG_TYPE',
type: Error
type: TypeError
});

const okInputs = [1, -1, '1', '-1', Date.now()];
Expand Down
7 changes: 5 additions & 2 deletions test/parallel/test-http2-client-http1-server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const http = require('http');
const http2 = require('http2');
const { NghttpError } = require('internal/http2/util');

// Creating an http1 server here...
const server = http.createServer(common.mustNotCall());
Expand All @@ -18,13 +20,14 @@ server.listen(0, common.mustCall(() => {

req.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
message: 'Protocol error'
}));

client.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]',
message: 'Protocol error'
}));

Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-http2-client-onconnect-errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
if (!common.hasCrypto)
Expand All @@ -10,6 +11,7 @@ const {
nghttp2ErrorString
} = process.binding('http2');
const http2 = require('http2');
const { NghttpError } = require('internal/http2/util');

// tests error handling within requestOnConnect
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
Expand Down Expand Up @@ -51,7 +53,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
ngError: constants[key],
error: {
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]',
message: nghttp2ErrorString(constants[key])
},
type: 'session'
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-http2-info-headers-errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
if (!common.hasCrypto)
Expand All @@ -9,6 +10,7 @@ const {
Http2Stream,
nghttp2ErrorString
} = process.binding('http2');
const { NghttpError } = require('internal/http2/util');

// tests error handling within additionalHeaders
// - every other NGHTTP2 error from binding (should emit stream error)
Expand All @@ -24,7 +26,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
ngError: constants[key],
error: {
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-http2-misbehaving-multiplex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');

Expand All @@ -7,6 +8,7 @@ if (!common.hasCrypto)

const h2 = require('http2');
const net = require('net');
const { NghttpError } = require('internal/http2/util');
const h2test = require('../common/http2');
let client;

Expand All @@ -18,7 +20,7 @@ server.on('stream', common.mustCall((stream) => {
server.on('session', common.mustCall((session) => {
session.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
message: 'Stream was already closed or invalid'
}));
}));
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-http2-respond-errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
if (!common.hasCrypto)
Expand All @@ -9,6 +10,7 @@ const {
Http2Stream,
nghttp2ErrorString
} = process.binding('http2');
const { NghttpError } = require('internal/http2/util');

// tests error handling within respond
// - every other NGHTTP2 error from binding (should emit stream error)
Expand All @@ -25,7 +27,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
ngError: constants[key],
error: {
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-http2-respond-with-fd-errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');

Expand All @@ -14,6 +15,7 @@ const {
Http2Stream,
nghttp2ErrorString
} = process.binding('http2');
const { NghttpError } = require('internal/http2/util');

// tests error handling within processRespondWithFD
// (called by respondWithFD & respondWithFile)
Expand All @@ -32,7 +34,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
ngError: constants[key],
error: {
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-http2-server-http1-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');

Expand All @@ -7,14 +8,15 @@ if (!common.hasCrypto)

const http = require('http');
const http2 = require('http2');
const { NghttpError } = require('internal/http2/util');

const server = http2.createServer();
server.on('stream', common.mustNotCall());
server.on('session', common.mustCall((session) => {
session.on('close', common.mustCall());
session.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
message: 'Received bad client magic byte string'
}));
}));
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-http2-server-push-stream-errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
if (!common.hasCrypto)
Expand All @@ -9,6 +10,7 @@ const {
Http2Stream,
nghttp2ErrorString
} = process.binding('http2');
const { NghttpError } = require('internal/http2/util');

// tests error handling within pushStream
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
Expand Down Expand Up @@ -49,7 +51,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
ngError: constants[key],
error: {
code: 'ERR_HTTP2_ERROR',
type: Error,
type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
Expand Down
6 changes: 5 additions & 1 deletion test/parallel/test-internal-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ assert.doesNotThrow(() => {
assert.doesNotThrow(() => {
common.expectsError(() => {
throw new errors.TypeError('TEST_ERROR_1', 'a');
}, { code: 'TEST_ERROR_1', type: Error });
}, {
code: 'TEST_ERROR_1',
type: TypeError,
message: 'Error for testing purposes: a'
});
});

common.expectsError(() => {
Expand Down
7 changes: 5 additions & 2 deletions test/parallel/test-ttywrap-invalid-fd.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
const fs = require('fs');
const tty = require('tty');
const { SystemError } = require('internal/errors');

common.expectsError(
() => new tty.WriteStream(-1),
Expand All @@ -27,7 +30,7 @@ common.expectsError(
new tty.WriteStream(fd);
}, {
code: 'ERR_SYSTEM_ERROR',
type: Error,
type: SystemError,
message
}
);
Expand All @@ -42,7 +45,7 @@ common.expectsError(
new tty.ReadStream(fd);
}, {
code: 'ERR_SYSTEM_ERROR',
type: Error,
type: SystemError,
message
});
}
Expand Down

0 comments on commit f26cabb

Please sign in to comment.