Merge branch 'master' into 5.x

This commit is contained in:
delvedor
2019-03-26 12:12:01 +01:00
271 changed files with 17840 additions and 1383 deletions

View File

@ -19,7 +19,7 @@
'use strict'
const { Client } = require('../../index')
const { Client, errors } = require('../../index')
const { buildServer } = require('../utils')
function runAsyncTest (test) {
@ -76,6 +76,21 @@ function runAsyncTest (test) {
server.stop()
})
})
test('async await (ConfigurationError)', async t => {
t.plan(1)
const client = new Client({
node: 'http://localhost:9200'
})
try {
await client.index({ body: { foo: 'bar' } })
t.fail('Should throw')
} catch (err) {
t.ok(err instanceof errors.ConfigurationError)
}
})
}
module.exports = runAsyncTest

View File

@ -20,7 +20,7 @@
'use strict'
const { test } = require('tap')
const { Client } = require('../../index')
const { Client, errors } = require('../../index')
const { buildServer } = require('../utils')
test('Basic (callback)', t => {
@ -295,6 +295,35 @@ test('If the API uses the same key for both url and query parameter, the url sho
})
})
test('ConfigurationError (callback)', t => {
t.plan(1)
const client = new Client({
node: 'http://localhost:9200'
})
client.index({
body: { foo: 'bar' }
}, (err, { body }) => {
t.ok(err instanceof errors.ConfigurationError)
})
})
test('ConfigurationError (promises)', t => {
t.plan(1)
const client = new Client({
node: 'http://localhost:9200'
})
client
.index({ body: { foo: 'bar' } })
.then(t.fail)
.catch(err => {
t.ok(err instanceof errors.ConfigurationError)
})
})
if (Number(process.version.split('.')[0].slice(1)) >= 8) {
require('./api-async')(test)
}