|
| 1 | +Feature: Table definitions in Lua file |
| 2 | + |
| 3 | + Scenario: Table definition needs a table parameter |
| 4 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 5 | + And the lua style |
| 6 | + """ |
| 7 | + local t = osm2pgsql.define_table() |
| 8 | + """ |
| 9 | + Then running osm2pgsql flex fails |
| 10 | + And the error output contains |
| 11 | + """ |
| 12 | + Argument #1 to 'define_table' must be a table. |
| 13 | + """ |
| 14 | + |
| 15 | + Scenario: Table definition needs a name |
| 16 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 17 | + And the lua style |
| 18 | + """ |
| 19 | + local t = osm2pgsql.define_table({}) |
| 20 | + """ |
| 21 | + Then running osm2pgsql flex fails |
| 22 | + And the error output contains |
| 23 | + """ |
| 24 | + The table must contain a 'name' string field. |
| 25 | + """ |
| 26 | + |
| 27 | + Scenario: Name in table definition has to be a string |
| 28 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 29 | + And the lua style |
| 30 | + """ |
| 31 | + local t = osm2pgsql.define_table({ |
| 32 | + name = false |
| 33 | + }) |
| 34 | + """ |
| 35 | + Then running osm2pgsql flex fails |
| 36 | + And the error output contains |
| 37 | + """ |
| 38 | + The table must contain a 'name' string field. |
| 39 | + """ |
| 40 | + |
| 41 | + Scenario: Table definition needs a column list |
| 42 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 43 | + And the lua style |
| 44 | + """ |
| 45 | + local t = osm2pgsql.define_table({ |
| 46 | + name = 'foo' |
| 47 | + }) |
| 48 | + """ |
| 49 | + Then running osm2pgsql flex fails |
| 50 | + And the error output contains |
| 51 | + """ |
| 52 | + No 'columns' field (or not an array) in table 'foo'. |
| 53 | + """ |
| 54 | + |
| 55 | + Scenario: The columns field must contain a table |
| 56 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 57 | + And the lua style |
| 58 | + """ |
| 59 | + local t = osm2pgsql.define_table({ |
| 60 | + name = 'foo', |
| 61 | + columns = 123 |
| 62 | + }) |
| 63 | + """ |
| 64 | + Then running osm2pgsql flex fails |
| 65 | + And the error output contains |
| 66 | + """ |
| 67 | + No 'columns' field (or not an array) in table 'foo'. |
| 68 | + """ |
| 69 | + |
| 70 | + Scenario: Table with empty columns list is not okay if there are no ids |
| 71 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 72 | + And the lua style |
| 73 | + """ |
| 74 | + local t = osm2pgsql.define_table({ |
| 75 | + name = 'foo', |
| 76 | + columns = {} |
| 77 | + }) |
| 78 | + """ |
| 79 | + Then running osm2pgsql flex fails |
| 80 | + And the error output contains |
| 81 | + """ |
| 82 | + No columns defined for table 'foo'. |
| 83 | + """ |
| 84 | + |
| 85 | + Scenario: Table with empty columns list is okay if there is an id column |
| 86 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 87 | + And the lua style |
| 88 | + """ |
| 89 | + local t = osm2pgsql.define_table({ |
| 90 | + name = 'foo', |
| 91 | + ids = { type = 'node', id_column = 'node_id' }, |
| 92 | + columns = {} |
| 93 | + }) |
| 94 | +
|
| 95 | + function osm2pgsql.process_node(object) |
| 96 | + t:insert({}) |
| 97 | + end |
| 98 | + """ |
| 99 | + When running osm2pgsql flex |
| 100 | + Then table foo has 1562 rows |
| 101 | + |
| 102 | + Scenario: Can not create two tables with the same name |
| 103 | + Given the input file 'liechtenstein-2013-08-03.osm.pbf' |
| 104 | + And the lua style |
| 105 | + """ |
| 106 | + local t1 = osm2pgsql.define_node_table('foo', { |
| 107 | + { column = 'bar' } |
| 108 | + }) |
| 109 | + local t2 = osm2pgsql.define_node_table('foo', { |
| 110 | + { column = 'baz' } |
| 111 | + }) |
| 112 | + """ |
| 113 | + Then running osm2pgsql flex fails |
| 114 | + And the error output contains |
| 115 | + """ |
| 116 | + Table with name 'foo' already exists. |
| 117 | + """ |
0 commit comments