-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from pelias/tag-generation-tests
Improve tag generation
- Loading branch information
Showing
5 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function generateParams(config) { | ||
const flags = []; | ||
|
||
if (config.tags) { | ||
const tags = config.tags.join(','); | ||
flags.push( `-tags=${tags}` ); | ||
} | ||
if( config.hasOwnProperty( 'leveldb' ) ){ | ||
flags.push( `-leveldb=${config.leveldb}` ); | ||
} | ||
|
||
flags.push( config.file ); | ||
|
||
return flags; | ||
} | ||
|
||
module.exports = generateParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const generateParams = require('../../lib/generateParams'); | ||
|
||
module.exports.tests = {}; | ||
|
||
module.exports.tests.params = function(test) { | ||
test('PBF file', function(t) { | ||
const config = { | ||
file: '/some/path/to/osm.pbf' | ||
}; | ||
|
||
const params = generateParams(config); | ||
|
||
t.equal(params[params.length - 1], '/some/path/to/osm.pbf', 'final parameter is path to PBF file'); | ||
t.end(); | ||
}); | ||
test('PBF file', function(t) { | ||
const config = { | ||
tags: [ | ||
'tag:one', | ||
'tag:two', | ||
'combination~tags' | ||
] | ||
}; | ||
|
||
const params = generateParams(config); | ||
|
||
const expected = '-tags=tag:one,tag:two,combination~tags'; | ||
|
||
t.equal(params[0], expected, 'tag array is serialized into parameter'); | ||
t.end(); | ||
}); | ||
}; | ||
|
||
module.exports.all = function (tape, common) { | ||
|
||
function test(name, testFunction) { | ||
return tape('generateParams: ' + name, testFunction); | ||
} | ||
|
||
for( var testCase in module.exports.tests ){ | ||
module.exports.tests[testCase](test, common); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters