Skip to content

Commit

Permalink
fix: don't use external URL in test
Browse files Browse the repository at this point in the history
  • Loading branch information
sandratatarevicova committed Apr 19, 2024
1 parent a13a9f5 commit bff885b
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions test/issue-3136.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
const { request } = require('..')
const { test, after } = require('node:test')
const net = require('node:net')
const { once } = require('node:events')
const assert = require('node:assert')

request('http://www.rolbox.it/rk-kastelruth/webcam/web03.jpg', { throwOnError: true })
.then(({ statusCode, body }) => {
console.log('then called', { statusCode })
body.on('err', e => console.error('body error:', e))
test('https://github.com/nodejs/undici/issues/3136', async (t) => {
const server = net.createServer((socket) => {
socket.write('HTTP/1.1 404 Not Found\r\n')
socket.write('Transfer-Encoding: chunked\r\n\r\n')
socket.write('\r\n')
})
.catch(e => console.error('catch called:', e))
.finally(() => console.log('finally called'))
after(() => server.close())
server.listen(0)
await once(server, 'listening')
await assert.rejects(
request(`http://localhost:${server.address().port}`, {
throwOnError: true
})
)
})

0 comments on commit bff885b

Please sign in to comment.