From f2946163d6a3ca5660b23541980fb7562aff8a00 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Wed, 31 Jul 2019 13:20:59 +0300 Subject: [PATCH] More cucumber tests for the nearest plugin to restore coverage metric --- features/nearest/pick.feature | 52 ++++++++++++++++++++++++++++ features/step_definitions/nearest.js | 6 ++++ 2 files changed, 58 insertions(+) diff --git a/features/nearest/pick.feature b/features/nearest/pick.feature index fb66ef654..dcdf5268c 100644 --- a/features/nearest/pick.feature +++ b/features/nearest/pick.feature @@ -59,6 +59,31 @@ Feature: Locating Nearest node on a Way - pick closest way | 3 | u | | 4 | w | + Scenario: Nearest - inside a oneway triangle + Given the node map + """ + c + + y z + 0 1 + 2 3 4 + a x u w b + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + | ca | yes | + + When I request nearest I should get + | in | out | + | 0 | y | + | 1 | z | + | 2 | x | + | 3 | u | + | 4 | w | + Scenario: Nearest - High lat/lon Given the node locations | node | lat | lon | @@ -78,3 +103,30 @@ Feature: Locating Nearest node on a Way - pick closest way | x | a | | y | b | | z | c | + + Scenario: Nearest - data version + Given the node map + """ + c + + y z + 0 1 + 2 3 4 + a x u w b + """ + + And the ways + | nodes | + | ab | + | bc | + | ca | + + And the extract extra arguments "--data_version cucumber_data_version" + + When I request nearest I should get + | in | out | data_version | + | 0 | y | cucumber_data_version | + | 1 | z | cucumber_data_version | + | 2 | x | cucumber_data_version | + | 3 | u | cucumber_data_version | + | 4 | w | cucumber_data_version | diff --git a/features/step_definitions/nearest.js b/features/step_definitions/nearest.js index f5627b842..65a34ede8 100644 --- a/features/step_definitions/nearest.js +++ b/features/step_definitions/nearest.js @@ -5,6 +5,7 @@ module.exports = function () { this.reprocessAndLoadData((e) => { if (e) return callback(e); var testRow = (row, ri, cb) => { + var inNode = this.findNodeByName(row.in); if (!inNode) throw new Error(util.format('*** unknown in-node "%s"', row.in)); @@ -14,6 +15,7 @@ module.exports = function () { this.requestNearest(inNode, this.queryParams, (err, response) => { if (err) return cb(err); var coord; + var headers = new Set(table.raw()[0]); if (response.statusCode === 200 && response.body.length) { var json = JSON.parse(response.body); @@ -22,6 +24,10 @@ module.exports = function () { var got = { in: row.in, out: row.out }; + if (headers.has('data_version')) { + got.data_version = json.data_version || ''; + } + Object.keys(row).forEach((key) => { if (key === 'out') { if (this.FuzzyMatch.matchLocation(coord, outNode)) {