Skip to content

Commit

Permalink
test: http2 test coverage for assertValidPseudoHeader
Browse files Browse the repository at this point in the history
PR-URL: #15105
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
  • Loading branch information
jasnell authored and MylesBorins committed Sep 12, 2017
1 parent 837c29c commit c0dba0f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/parallel/test-http2-util-assert-valid-pseudoheader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Flags: --expose-internals
'use strict';

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

// Tests the assertValidPseudoHeader function that is used within the
// mapToHeaders function. The assert function is not exported so we
// have to test it through mapToHeaders

const { mapToHeaders } = require('internal/http2/util');
const assert = require('assert');

function isNotError(val) {
assert(!(val instanceof Error));
}

function isError(val) {
common.expectsError({
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
type: Error,
message: '":foo" is an invalid pseudoheader or is used incorrectly'
})(val);
}

isNotError(mapToHeaders({ ':status': 'a' }));
isNotError(mapToHeaders({ ':path': 'a' }));
isNotError(mapToHeaders({ ':authority': 'a' }));
isNotError(mapToHeaders({ ':scheme': 'a' }));
isNotError(mapToHeaders({ ':method': 'a' }));

isError(mapToHeaders({ ':foo': 'a' }));

0 comments on commit c0dba0f

Please sign in to comment.