File: lua-table-definitions.feature

package info (click to toggle)
osm2pgsql 2.1.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,652 kB
  • sloc: cpp: 59,934; python: 1,039; ansic: 763; sh: 25; makefile: 14
file content (151 lines) | stat: -rw-r--r-- 4,848 bytes parent folder | download | duplicates (2)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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: Unique index is okay
        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', index = 'unique' },
                columns = {}
            })

            function osm2pgsql.process_node(object)
                t:insert({})
            end
            """
        When running osm2pgsql flex
        Then table foo has 1562 rows

    Scenario: Primary key is okay
        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', index = 'primary_key' },
                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.
            """