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