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
Backport-PR-URL: #19579
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 authored and targos committed Mar 30, 2018
1 parent 44b12c1 commit ca97be5
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-crypto-sign-verify.js
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
7 changes: 5 additions & 2 deletions test/parallel/test-http2-client-http1-server.js
@@ -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
@@ -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
@@ -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
@@ -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 @@ -25,7 +27,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
@@ -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
@@ -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
@@ -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
@@ -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
2 changes: 2 additions & 0 deletions test/parallel/test-ttywrap-invalid-fd.js
@@ -1,4 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
const assert = require('assert');
const fs = require('fs');
Expand Down

0 comments on commit ca97be5

Please sign in to comment.