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
Update return client.close()
  • Loading branch information
sosukesuzuki committed Jan 11, 2024
commit 7aaff7abfc2b5b0be4adcbc448daa34adf525867
2 changes: 1 addition & 1 deletion test/node-test/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ test('async hooks pipeline handler', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

setCurrentTransaction({ hello: 'world2' })

Expand Down
8 changes: 4 additions & 4 deletions test/node-test/client-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test('basic connect', async (t) => {

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const signal = new EE()
const promise = client.connect({
Expand Down Expand Up @@ -69,7 +69,7 @@ test('connect error', async (t) => {

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

try {
await client.connect({
Expand Down Expand Up @@ -137,7 +137,7 @@ test('connect wait for empty pipeline', async (t) => {
const client = new Client(`http://localhost:${server.address().port}`, {
pipelining: 3
})
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.request({
path: '/',
Expand Down Expand Up @@ -242,7 +242,7 @@ test('basic connect error', async (t) => {

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const _err = new Error()
client.connect({
Expand Down
42 changes: 21 additions & 21 deletions test/node-test/client-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ test('basic dispatch get', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const bufs = []
client.dispatch({
Expand Down Expand Up @@ -166,7 +166,7 @@ test('trailers dispatch get', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const bufs = []
client.dispatch({
Expand Down Expand Up @@ -214,7 +214,7 @@ test('dispatch onHeaders error', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const _err = new Error()
client.dispatch({
Expand Down Expand Up @@ -251,7 +251,7 @@ test('dispatch onComplete error', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const _err = new Error()
client.dispatch({
Expand Down Expand Up @@ -288,7 +288,7 @@ test('dispatch onData error', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const _err = new Error()
client.dispatch({
Expand Down Expand Up @@ -325,7 +325,7 @@ test('dispatch onConnect error', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

const _err = new Error()
client.dispatch({
Expand Down Expand Up @@ -375,7 +375,7 @@ test('connect call onUpgrade once', async (t) => {

server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

let recvData = ''
let count = 0
Expand Down Expand Up @@ -427,7 +427,7 @@ test('dispatch onConnect missing', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.dispatch({
path: '/',
Expand Down Expand Up @@ -461,7 +461,7 @@ test('dispatch onHeaders missing', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.dispatch({
path: '/',
Expand Down Expand Up @@ -494,7 +494,7 @@ test('dispatch onData missing', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.dispatch({
path: '/',
Expand Down Expand Up @@ -527,7 +527,7 @@ test('dispatch onComplete missing', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.dispatch({
path: '/',
Expand Down Expand Up @@ -560,7 +560,7 @@ test('dispatch onError missing', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

try {
client.dispatch({
Expand Down Expand Up @@ -628,7 +628,7 @@ test('dispatch upgrade onUpgrade missing', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.dispatch({
path: '/',
Expand Down Expand Up @@ -659,7 +659,7 @@ test('dispatch pool onError missing', async (t) => {

server.listen(0, () => {
const client = new Pool(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

try {
client.dispatch({
Expand All @@ -686,7 +686,7 @@ test('dispatch onBodySent not a function', async (t) => {

server.listen(0, () => {
const client = new Pool(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.dispatch({
path: '/',
Expand Down Expand Up @@ -716,7 +716,7 @@ test('dispatch onBodySent buffer', async (t) => {

server.listen(0, () => {
const client = new Pool(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })
const body = 'hello 🚀'
client.dispatch({
path: '/',
Expand Down Expand Up @@ -755,7 +755,7 @@ test('dispatch onBodySent stream', async (t) => {
const body = stream.Readable.from(chunks)
server.listen(0, () => {
const client = new Pool(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })
let sentBytes = 0
let currentChunk = 0
client.dispatch({
Expand Down Expand Up @@ -796,7 +796,7 @@ test('dispatch onBodySent async-iterable', (t, done) => {
const toSendBytes = chunks.reduce((a, b) => a + Buffer.byteLength(b), 0)
server.listen(0, () => {
const client = new Pool(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })
let sentBytes = 0
let currentChunk = 0
client.dispatch({
Expand Down Expand Up @@ -831,7 +831,7 @@ test('dispatch onBodySent throws error', (t, done) => {

server.listen(0, () => {
const client = new Pool(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })
const body = 'hello'
client.dispatch({
path: '/',
Expand Down Expand Up @@ -865,7 +865,7 @@ test('dispatches in expected order', async (t) => {
server.listen(0, () => {
const client = new Pool(`http://localhost:${server.address().port}`)

t.after(() => { client.close() })
t.after(() => { return client.close() })

const dispatches = []

Expand Down Expand Up @@ -924,7 +924,7 @@ test('dispatches in expected order for http2', async (t) => {
allowH2: true
})

t.after(() => { client.close() })
t.after(() => { return client.close() })

const dispatches = []

Expand Down
4 changes: 2 additions & 2 deletions test/node-test/client-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ test('validate request body', async (t) => {

server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.request({
path: '/',
Expand Down Expand Up @@ -1046,7 +1046,7 @@ test('retry idempotent inflight', async (t) => {
const client = new Client(`http://localhost:${server.address().port}`, {
pipelining: 3
})
t.after(() => { client.close() })
t.after(() => { return client.close() })

client.request({
path: '/',
Expand Down