Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/client-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ test('connect aborted after connect', async (t) => {
pipelining: 3
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

client.connect({
path: '/',
Expand Down
40 changes: 40 additions & 0 deletions test/client-pipelining.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ test('20 times GET with pipelining 10', async (t) => {
pipelining: 10
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

for (let i = 0; i < num; i++) {
makeRequest(i)
Expand Down Expand Up @@ -98,6 +103,11 @@ test('A client should enqueue as much as twice its pipelining factor', async (t)
pipelining: 2
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

for (; sent < 2;) {
t.ok(client[kSize] <= client.pipelining, 'client is not full')
Expand Down Expand Up @@ -148,6 +158,11 @@ test('pipeline 1 is 1 active request', async (t) => {
pipelining: 1
})
after(() => client.destroy())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})
client.request({
path: '/',
method: 'GET'
Expand Down Expand Up @@ -201,6 +216,11 @@ test('pipelined chunked POST stream', async (t) => {
pipelining: 2
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

client.request({
path: '/',
Expand Down Expand Up @@ -270,6 +290,11 @@ test('pipelined chunked POST iterator', async (t) => {
pipelining: 2
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

client.request({
path: '/',
Expand Down Expand Up @@ -393,6 +418,11 @@ test('pipelining non-idempotent', async (t) => {
pipelining: 2
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

let ended = false
client.request({
Expand Down Expand Up @@ -439,6 +469,11 @@ function pipeliningNonIdempotentWithBody (bodyType) {
pipelining: 2
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

let ended = false
let reading = false
Expand Down Expand Up @@ -747,6 +782,11 @@ test('pipelining blocked', async (t) => {
pipelining: 10
})
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})
client.request({
path: '/',
method: 'GET',
Expand Down
10 changes: 10 additions & 0 deletions test/client-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ test('request post blob', async (t) => {

const client = new Client(`http://localhost:${server.address().port}`)
after(client.destroy.bind(client))
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

client.request({
path: '/',
Expand Down Expand Up @@ -62,6 +67,11 @@ test('request post arrayBuffer', async (t) => {

const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.destroy())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

const buf = Buffer.from('asd')
const dst = new ArrayBuffer(buf.byteLength)
Expand Down
60 changes: 60 additions & 0 deletions test/client-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ test('stream get', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

const signal = new EE()
client.stream({
Expand Down Expand Up @@ -65,6 +70,11 @@ test('stream promise get', async (t) => {
server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

await client.stream({
path: '/',
Expand Down Expand Up @@ -254,6 +264,11 @@ test('stream waits only for writable side', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

const pt = new PassThrough({ autoDestroy: false })
client.stream({
Expand Down Expand Up @@ -321,6 +336,11 @@ test('stream destroy if not readable', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(client.destroy.bind(client))
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

client.stream({
path: '/',
Expand Down Expand Up @@ -397,6 +417,11 @@ test('stream body without destroy', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(client.destroy.bind(client))
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

client.stream({
path: '/',
Expand Down Expand Up @@ -520,6 +545,11 @@ test('stream abort after complete', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(client.destroy.bind(client))
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

const pt = new PassThrough()
const signal = new EE()
Expand Down Expand Up @@ -580,6 +610,11 @@ test('trailers', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

client.stream({
path: '/',
Expand All @@ -605,6 +640,11 @@ test('stream ignore 1xx', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

let buf = ''
client.stream({
Expand Down Expand Up @@ -637,6 +677,11 @@ test('stream ignore 1xx and use onInfo', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

let buf = ''
client.stream({
Expand Down Expand Up @@ -675,6 +720,11 @@ test('stream backpressure', async (t) => {
server.listen(0, () => {
const client = new Client(`http://localhost:${server.address().port}`)
after(() => client.close())
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

let buf = ''
client.stream({
Expand Down Expand Up @@ -736,6 +786,11 @@ test('stream needDrain', async (t) => {
after(() => {
client.destroy()
})
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

const dst = new PassThrough()
dst.pause()
Expand Down Expand Up @@ -792,6 +847,11 @@ test('stream legacy needDrain', async (t) => {
after(() => {
client.destroy()
})
client.on('disconnect', () => {
if (!client.closed && !client.destroyed) {
t.fail('unexpected disconnect')
}
})

const dst = new PassThrough()
dst.pause()
Expand Down
Loading