mirror of https://github.com/pelias/api.git
Stephen Hess
8 years ago
13 changed files with 48 additions and 96 deletions
@ -1,6 +0,0 @@
|
||||
const config = require( 'pelias-config' ).generate().esclient; |
||||
const client = require('elasticsearch').Client(config); |
||||
|
||||
module.exports = { |
||||
client: client |
||||
}; |
@ -1,40 +0,0 @@
|
||||
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…
Reference in new issue