Skip to content

Commit

Permalink
Check the proper admin lookup config properties
Browse files Browse the repository at this point in the history
The admin lookup stream code was incorrectly checking the wrong
property, making it harder to enable admin lookup.

Thanks to @DylanFrese for helping us figure this out.

Related: pelias/wof-admin-lookup#52
Fixes pelias/wof-admin-lookup#51
  • Loading branch information
orangejulius committed Jun 10, 2016
1 parent 6639116 commit 9786e94
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
8 changes: 1 addition & 7 deletions stream/adminLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ function createStream(config, adminLookup) {
return sendPassthroughStream();
}

// admin lookup disabled
if (!config.imports.openstreetmap.adminLookup) {
return sendPassthroughStream();
}

// admin lookup enabled
if (config.imports.adminLookup) {
//var pipResolver = adminLookup.createWofPipResolver(config.imports.adminLookup.url);
if (config.imports.openstreetmap.adminLookup) {
var pipResolver = adminLookup.createLocalWofPipResolver();
return adminLookup.createLookupStream(pipResolver);
} else {
Expand Down
34 changes: 33 additions & 1 deletion test/stream/adminLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@ module.exports.tests.enabled = function(test, common) {

};

module.exports.tests.enabled_without_admin_lookup_config = function(test, common) {
var config = {
imports: {
openstreetmap: {
adminLookup: true
}
}
};

/*
* There was a bug (https://github.com/pelias/wof-admin-lookup/issues/51) where admin lookup could
* not be enabled without the adminLookup config section
*/
test('enabled without any special adminLookup config: return pip stream', function (t) {
t.plan(1);

var streamMock = {madeBy: 'mock'};

var wofAdminLookup = {
createLocalWofPipResolver: function() {
},
createLookupStream: function() {
return streamMock;
}
};

var stream = adminLookup(config, wofAdminLookup);
t.equal(stream, streamMock, 'stream created');
t.end();
});
};

module.exports.tests.disabled = function (test, common) {
var config = {
imports: {
Expand Down Expand Up @@ -105,4 +137,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};

0 comments on commit 9786e94

Please sign in to comment.