Skip to content

Commit

Permalink
switched to 0-parameter wof-admin-lookup createLookupStream
Browse files Browse the repository at this point in the history
* modified tests to proxyquire pelias-config instead of writing to /tmp since not everyone is on linux or has write access to /tmp
* update lint to es6
  • Loading branch information
trescube committed Feb 9, 2017
1 parent c1a17d9 commit d04cc57
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 40 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Expand Up @@ -2,6 +2,7 @@
"node": true,
"curly": true,
"eqeqeq": true,
"esversion": 6,
"freeze": true,
"immed": true,
"indent": 2,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -39,16 +39,18 @@
"pelias-dbclient": "2.0.0",
"pelias-logger": "0.1.0",
"pelias-model": "4.4.0",
"pelias-wof-admin-lookup": "2.11.0",
"pelias-wof-admin-lookup": "pelias/wof-admin-lookup#incorporate-pip-service-directly",
"polyline": "^0.2.0",
"split": "^1.0.0",
"through2": "^2.0.1",
"turf-along": "^3.0.12",
"turf-line-distance": "^3.0.12"
},
"devDependencies": {
"event-stream": "^3.3.4",
"jshint": "^2.9.2",
"precommit-hook": "^3.0.0",
"proxyquire": "^1.7.11",
"tap-spec": "^4.1.1",
"tape": "^4.6.0"
},
Expand Down
17 changes: 0 additions & 17 deletions stream/adminLookup.js

This file was deleted.

2 changes: 1 addition & 1 deletion stream/pipeline.js
Expand Up @@ -6,7 +6,7 @@ var split = require('split'),
unwrap = require('./unwrap'),
centroid = require('./centroid'),
document = require('./document'),
adminLookup = require('./adminLookup');
adminLookup = require('pelias-wof-admin-lookup').createLookupStream;

function pipeline( streamIn, streamOut ){
return streamIn
Expand Down
41 changes: 20 additions & 21 deletions test/stream/pipeline.js
@@ -1,30 +1,23 @@

var fs = require('fs'),
through = require('through2'),
pipeline = require('../../stream/pipeline');
pipeline = require('../../stream/pipeline'),
proxyquire = require('proxyquire').noCallThru();

module.exports.tests = {};

// use default pelias config
function setup(){
var defaults = JSON.stringify( require('pelias-config').defaults, null, 2 );
fs.writeFileSync('/tmp/tmpPelias.json', defaults, { encoding: 'utf8' });
process.env.PELIAS_CONFIG = '/tmp/tmpPelias.json';
}

// clean up
function teardown(){
delete process.env.PELIAS_CONFIG;
fs.unlinkSync('/tmp/tmpPelias.json');
}

// interface
module.exports.tests.interface = function(test, common) {

test('interface: stream', function(t) {
setup();
var stream = pipeline( through(), through() );
teardown();
const stream = proxyquire('../../stream/pipeline', {
'pelias-wof-admin-lookup': {
createLookupStream: () => {
return through();
}
}
})(through(), through());

t.equal(typeof stream, 'object', 'valid stream');
t.equal(typeof stream._read, 'function', 'valid readable');
t.equal(typeof stream._write, 'function', 'valid writeable');
Expand Down Expand Up @@ -54,10 +47,16 @@ module.exports.tests.end_to_end = function(test, common) {
t.end();
});

// run pipeline
setup();
pipeline( fixture, sink );
teardown();
const stream = proxyquire('../../stream/pipeline', {
'pelias-wof-admin-lookup': {
createLookupStream: () => {
return through.obj();
}
}
});

stream(fixture, sink);

});
};

Expand Down

0 comments on commit d04cc57

Please sign in to comment.