|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | | -const { execSync } = require('node:child_process') |
| 3 | +const { tspl } = require('@matteo.collina/tspl') |
| 4 | +const { exec } = require('node:child_process') |
4 | 5 | const { test } = require('node:test') |
5 | | -const assert = require('node:assert') |
6 | 6 |
|
7 | 7 | const command = 'node -e "require(\'./undici-fetch.js\').fetch(\'https://httpbin.org/get\')"' |
8 | 8 |
|
9 | | -test("respect Node.js' --max-http-header-size", async () => { |
10 | | - assert.throws( |
11 | | - () => execSync(`${command} --max-http-header-size=1`), |
12 | | - /UND_ERR_HEADERS_OVERFLOW/, |
13 | | - 'max-http-header-size=1 should throw' |
14 | | - ) |
| 9 | +test("respect Node.js' --max-http-header-size", async (t) => { |
| 10 | + t = tspl(t, { plan: 6 }) |
15 | 11 |
|
16 | | - assert.doesNotThrow( |
17 | | - () => execSync(command), |
18 | | - /UND_ERR_HEADERS_OVERFLOW/, |
19 | | - 'default max-http-header-size should not throw' |
20 | | - ) |
| 12 | + exec(`${command} --max-http-header-size=1`, { stdio: 'pipe' }, (err, stdout, stderr) => { |
| 13 | + t.strictEqual(err.code, 1) |
| 14 | + t.strictEqual(stdout, '') |
| 15 | + t.match(stderr, /UND_ERR_HEADERS_OVERFLOW/, '--max-http-header-size=1 should throw') |
| 16 | + }) |
| 17 | + |
| 18 | + exec(command, { stdio: 'pipe' }, (err, stdout, stderr) => { |
| 19 | + t.ifError(err) |
| 20 | + t.strictEqual(stdout, '') |
| 21 | + t.strictEqual(stderr, '', 'default max-http-header-size should not throw') |
| 22 | + }) |
| 23 | + |
| 24 | + await t.completed |
21 | 25 | }) |
0 commit comments