Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: port client-connect, client-dispatch, client-errors test to node:test #2591

Merged
merged 11 commits into from
Jan 16, 2024
Prev Previous commit
Next Next commit
Use closeServerAsPromise for client-connect
  • Loading branch information
sosukesuzuki committed Jan 11, 2024
commit 62dd4fff9e79dbab00d02ac6782e54183419ffbb
14 changes: 8 additions & 6 deletions test/node-test/client-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const http = require('http')
const EE = require('events')
const { kBusy } = require('../../lib/core/symbols')
const { tspl } = require('@matteo.collina/tspl')
const { closeServerAsPromise } = require('../utils/node-http')

test('basic connect', async (t) => {
const p = tspl(t, { plan: 3 })
Expand All @@ -25,7 +26,7 @@ test('basic connect', async (t) => {
socket.end(data)
})
})
t.after(server.close.bind(server))
t.after(closeServerAsPromise(server))

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
Expand Down Expand Up @@ -65,7 +66,7 @@ test('connect error', async (t) => {
server.on('connect', (req, socket, firstBodyChunk) => {
socket.destroy()
})
t.after(server.close.bind(server))
t.after(closeServerAsPromise(server))

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
Expand Down Expand Up @@ -131,7 +132,7 @@ test('connect wait for empty pipeline', async (t) => {
socket.end(data)
})
})
t.after(server.close.bind(server))
t.after(closeServerAsPromise(server))

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`, {
Expand Down Expand Up @@ -188,7 +189,7 @@ test('connect aborted', async (t) => {
server.on('connect', (req, c, firstBodyChunk) => {
p.ok(0)
})
t.after(server.close.bind(server))
t.after(closeServerAsPromise(server))

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`, {
Expand Down Expand Up @@ -238,7 +239,7 @@ test('basic connect error', async (t) => {
socket.end(data)
})
})
t.after(server.close.bind(server))
t.after(closeServerAsPromise(server))

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
Expand Down Expand Up @@ -268,7 +269,7 @@ test('connect invalid signal', async (t) => {
server.on('connect', (req, c, firstBodyChunk) => {
p.ok(0)
})
t.after(server.close.bind(server))
t.after(closeServerAsPromise(server))

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
Expand Down Expand Up @@ -301,6 +302,7 @@ test('connect aborted after connect', async (t) => {
server.on('connect', (req, c, firstBodyChunk) => {
signal.emit('abort')
})
// FIXME: use closeServerAsPromise
t.after(server.close.bind(server))

server.listen(0, () => {
Expand Down