Skip to content

Commit 633772a

Browse files
stropitekMylesBorins
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 dd23140 commit 633772a

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
@@ -2,38 +2,32 @@
22
'use strict';
33

44
const common = require('../common');
5+
const fixtures = require('../common/fixtures');
56

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

910
const assert = require('assert');
1011
const http2 = require('http2');
1112
const fs = require('fs');
12-
const path = require('path');
1313
const tls = require('tls');
1414

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

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

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

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

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

0 commit comments

Comments
 (0)