Updated test

This commit is contained in:
delvedor
2018-12-18 17:29:06 +01:00
parent 32e674f26c
commit 7a181ff9ac
2 changed files with 15 additions and 2 deletions

View File

@ -252,7 +252,7 @@ TestRunner.prototype.set = function (key, name) {
TestRunner.prototype.do = function (action, done) {
const cmd = this.parseDo(action)
const api = delve(this.client, cmd.method).bind(this.client)
const options = { ignore: cmd.params.ignore, headers: cmd.params.headers }
const options = { ignore: cmd.params.ignore, headers: action.headers }
api(cmd.params, options, (err, { body, warnings }) => {
if (action.warnings && warnings === null) {
this.tap.fail('We should get a warning header', action.warnings)

View File

@ -6,7 +6,7 @@ const { URL } = require('url')
const intoStream = require('into-stream')
const { buildServer } = require('../utils')
const Connection = require('../../lib/Connection')
const { TimeoutError } = require('../../lib/errors')
const { TimeoutError, ConfigurationError } = require('../../lib/errors')
test('Basic (http)', t => {
t.plan(4)
@ -560,3 +560,16 @@ test('Connection id should not contain credentials', t => {
t.strictEqual(connection.id, 'http://localhost:9200/')
t.end()
})
test('Should throw if the protocol is not http or https', t => {
try {
new Connection({ // eslint-disable-line
url: new URL('nope://nope')
})
t.fail('Should throw')
} catch (err) {
t.ok(err instanceof ConfigurationError)
t.is(err.message, 'Invalid protocol: \'nope:\'')
}
t.end()
})