Skip to content

Commit

Permalink
Merge pull request #177 from pelias/provide-local-pip-resolver-function
Browse files Browse the repository at this point in the history
feat: Expose localPipResolver function
  • Loading branch information
orangejulius authored Nov 20, 2017
2 parents 5b9672d + 0ff8bbe commit 5c36d6d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ function resolver(layers) {
if (_.has(peliasConfig, 'imports.services.pip')) {
return require('./src/remotePipResolver')(peliasConfig.imports.services.pip, layers);
} else {
const datapath = peliasConfig.imports.whosonfirst.datapath;
return require('./src/localPipResolver')(datapath, layers);
return localResolver(layers);
}
}

function localResolver(layers) {
const datapath = peliasConfig.imports.whosonfirst.datapath;
return require('./src/localPipResolver')(datapath, layers);
}

module.exports = {
create: create,
resolver: resolver
resolver: resolver,
localResolver: localResolver
};
36 changes: 36 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,40 @@ tape('tests for main entry point', (test) => {

});

test.test('localResolver function should return local resolver even if resolver would return a remote resolver', (t) => {
const resolver = proxyquire('../index', {
// verify the schema
'./schema': 'this is the schema',
'pelias-config': {
generate: (schema) => {
t.equals(schema, 'this is the schema');

return {
imports: {
adminLookup: {
enabled: true,
maxConcurrentReqs: 21
},
whosonfirst: {
datapath: 'this is the wof datapath'
},
services: {
pip: {
url: 'this is the url'
}
}
}
};

}
},
'./src/localPipResolver': (datapath, layers) => {
t.equals(datapath, 'this is the wof datapath');
t.deepEquals(layers, ['layer 1', 'layer 2']);
return 'this is the resolver';
}
}).localResolver(['layer 1', 'layer 2']);
t.equal(resolver, 'this is the resolver');
t.end();
});
});

0 comments on commit 5c36d6d

Please sign in to comment.