Browse Source

Merge branch 'master' of github.com:pelias/api into expose-bbox

pull/443/head
Diana Shkolnikov 9 years ago
parent
commit
663c2ad232
  1. 2
      package.json
  2. 4
      src/backend.js
  3. 1
      test/unit/run.js
  4. 40
      test/unit/src/backend.js

2
package.json

@ -53,7 +53,7 @@
"morgan": "1.7.0",
"pelias-config": "^1.0.1",
"pelias-logger": "^0.0.8",
"pelias-query": "^6.0.0",
"pelias-query": "^6.1.0",
"pelias-suggester-pipeline": "2.0.4",
"stats-lite": "1.0.3",
"through2": "2.0.1"

4
src/backend.js

@ -1,6 +1,6 @@
var config = require( 'pelias-config' ).generate().esclient;
var Backend = require('geopipes-elasticsearch-backend'),
client = require('elasticsearch').Client(),
client = require('elasticsearch').Client(config),
backends = {};
function getBackend( index, type ){

1
test/unit/run.js

@ -46,6 +46,7 @@ var tests = [
require('./sanitiser/_sources'),
require('./sanitiser/_sources_and_layers'),
require('./sanitiser/_text'),
require('./src/backend'),
require('./sanitiser/autocomplete'),
require('./sanitiser/place'),
require('./sanitiser/reverse'),

40
test/unit/src/backend.js

@ -0,0 +1,40 @@
var proxyquire = require('proxyquire');
var stubConfig = {
generate: function generate() {
return {
esclient: {
hosts: [
'http://notLocalhost:9200',
'http://anotherHost:9200'
]
}
};
}
};
module.exports.tests = {};
module.exports.tests.config_properly_passed = function(test, common) {
test('Elasticsearch config is properly passed to elasticsearch module', function(t) {
var stubElasticsearchClient = {
Client: function(config) {
t.deepEquals(config.hosts, [ 'http://notLocalhost:9200', 'http://anotherHost:9200' ], 'hosts set correctly' );
t.end();
}
};
proxyquire('../../../src/backend', { 'pelias-config': stubConfig, 'elasticsearch': stubElasticsearchClient } );
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('SANTIZE src/backend ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
Loading…
Cancel
Save