-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix server closing in tests. (#3279)
- Loading branch information
1 parent
5a564bd
commit dcfaeca
Showing
2 changed files
with
21 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
'use strict' | ||
|
||
const { execSync } = require('node:child_process') | ||
const { tspl } = require('@matteo.collina/tspl') | ||
const { exec } = require('node:child_process') | ||
const { test } = require('node:test') | ||
const assert = require('node:assert') | ||
|
||
const command = 'node -e "require(\'./undici-fetch.js\').fetch(\'https://httpbin.org/get\')"' | ||
|
||
test("respect Node.js' --max-http-header-size", async () => { | ||
assert.throws( | ||
() => execSync(`${command} --max-http-header-size=1`), | ||
/UND_ERR_HEADERS_OVERFLOW/, | ||
'max-http-header-size=1 should throw' | ||
) | ||
test("respect Node.js' --max-http-header-size", async (t) => { | ||
t = tspl(t, { plan: 6 }) | ||
|
||
assert.doesNotThrow( | ||
() => execSync(command), | ||
/UND_ERR_HEADERS_OVERFLOW/, | ||
'default max-http-header-size should not throw' | ||
) | ||
exec(`${command} --max-http-header-size=1`, { stdio: 'pipe' }, (err, stdout, stderr) => { | ||
t.strictEqual(err.code, 1) | ||
t.strictEqual(stdout, '') | ||
t.match(stderr, /UND_ERR_HEADERS_OVERFLOW/, '--max-http-header-size=1 should throw') | ||
}) | ||
|
||
exec(command, { stdio: 'pipe' }, (err, stdout, stderr) => { | ||
t.ifError(err) | ||
t.strictEqual(stdout, '') | ||
t.strictEqual(stderr, '', 'default max-http-header-size should not throw') | ||
}) | ||
|
||
await t.completed | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters