Catch HEAD errors (#1460)

This commit is contained in:
Tomas Della Vedova
2021-05-03 16:40:09 +02:00
committed by GitHub
parent dc2de57bd3
commit d5f61c7833
2 changed files with 6 additions and 4 deletions

View File

@ -1613,7 +1613,7 @@ test('Should cast to boolean HEAD request', t => {
})
t.test('4xx response', t => {
t.plan(2)
t.plan(3)
const pool = new ConnectionPool({ Connection: MockConnection })
pool.addConnection('http://localhost:9200')
@ -1633,12 +1633,13 @@ test('Should cast to boolean HEAD request', t => {
path: '/400'
}, (err, { body, statusCode }) => {
t.ok(err instanceof ResponseError)
t.false(typeof err.body === 'boolean')
t.strictEqual(statusCode, 400)
})
})
t.test('5xx response', t => {
t.plan(2)
t.plan(3)
const pool = new ConnectionPool({ Connection: MockConnection })
pool.addConnection('http://localhost:9200')
@ -1657,6 +1658,7 @@ test('Should cast to boolean HEAD request', t => {
path: '/500'
}, (err, { body, statusCode }) => {
t.ok(err instanceof ResponseError)
t.false(typeof err.body === 'boolean')
t.strictEqual(statusCode, 500)
})
})