Skip to content

Commit 96221c2

Browse files
stropitekBridgeAR
authored andcommitted
test: refactor test to use the fixtures module
PR-URL: #15934 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
1 parent 2bf182d commit 96221c2

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

test/parallel/test-http2-serve-file.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11
'use strict';
22

33
const common = require('../common');
4+
const fixtures = require('../common/fixtures');
45

56
if (!common.hasCrypto)
67
common.skip('missing crypto');
78

89
const assert = require('assert');
910
const http2 = require('http2');
1011
const fs = require('fs');
11-
const path = require('path');
1212
const tls = require('tls');
1313

14-
const ajs_data = fs.readFileSync(path.resolve(common.fixturesDir, 'a.js'),
15-
'utf8');
14+
const ajs_data = fixtures.readSync('a.js', 'utf8');
1615

1716
const {
1817
HTTP2_HEADER_PATH,
1918
HTTP2_HEADER_STATUS
2019
} = http2.constants;
2120

22-
function loadKey(keyname) {
23-
return fs.readFileSync(
24-
path.join(common.fixturesDir, 'keys', keyname), 'binary');
25-
}
26-
27-
const key = loadKey('agent8-key.pem');
28-
const cert = loadKey('agent8-cert.pem');
29-
const ca = loadKey('fake-startcom-root-cert.pem');
21+
const key = fixtures.readKey('agent8-key.pem', 'binary');
22+
const cert = fixtures.readKey('agent8-cert.pem', 'binary');
23+
const ca = fixtures.readKey('fake-startcom-root-cert.pem', 'binary');
3024

3125
const server = http2.createSecureServer({ key, cert });
3226

3327
server.on('stream', (stream, headers) => {
3428
const name = headers[HTTP2_HEADER_PATH].slice(1);
35-
const file = path.resolve(common.fixturesDir, name);
29+
const file = fixtures.path(name);
3630
fs.stat(file, (err, stat) => {
3731
if (err != null || stat.isDirectory()) {
3832
stream.respond({ [HTTP2_HEADER_STATUS]: 404 });

0 commit comments

Comments
 (0)