Skip to content

Commit 1199f90

Browse files
committed
Test that no maxzoom setting works on you'll get expire on zoom 0
1 parent 616d015 commit 1199f90

File tree

3 files changed

+151
-0
lines changed

3 files changed

+151
-0
lines changed

tests/bdd/flex/expire.feature

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
Feature: Changes on way with expire on zoom 0
2+
3+
Background:
4+
Given the style file 'test_expire.lua'
5+
6+
And the 0.1 grid
7+
| 11 | 13 |
8+
| 10 | 12 |
9+
10+
And the OSM data
11+
"""
12+
w11 v1 dV Tt1=yes Nn12,n13
13+
"""
14+
When running osm2pgsql flex with parameters
15+
| --slim |
16+
17+
Then table osm2pgsql_test_t1 contains exactly
18+
| way_id |
19+
| 11 |
20+
Then table osm2pgsql_test_expire contains exactly
21+
| zoom | x | y |
22+
23+
24+
Scenario: way is not relevant
25+
Given the OSM data
26+
"""
27+
w10 v1 dV Ta=b Nn10,n11
28+
"""
29+
And an empty grid
30+
31+
When running osm2pgsql flex with parameters
32+
| --slim | -a |
33+
34+
Then table osm2pgsql_test_t1 contains exactly
35+
| way_id |
36+
| 11 |
37+
Then table osm2pgsql_test_expire contains exactly
38+
| zoom | x | y |
39+
40+
41+
Scenario: node is not relevant
42+
Given the OSM data
43+
"""
44+
n1 v2 dV x1 y2
45+
"""
46+
And an empty grid
47+
48+
When running osm2pgsql flex with parameters
49+
| --slim | -a |
50+
51+
Then table osm2pgsql_test_t1 contains exactly
52+
| way_id |
53+
| 11 |
54+
Then table osm2pgsql_test_expire contains exactly
55+
| zoom | x | y |
56+
57+
58+
Scenario: add to t1
59+
Given the OSM data
60+
"""
61+
w10 v1 dV Tt1=yes Nn10,n11
62+
"""
63+
And an empty grid
64+
65+
When running osm2pgsql flex with parameters
66+
| --slim | -a |
67+
68+
Then table osm2pgsql_test_t1 contains exactly
69+
| way_id |
70+
| 10 |
71+
| 11 |
72+
Then table osm2pgsql_test_expire contains exactly
73+
| zoom | x | y |
74+
| 0 | 0 | 0 |
75+
76+
77+
Scenario: change in t1
78+
Given the OSM data
79+
"""
80+
w11 v2 dV Ta=b Nn10,n11
81+
"""
82+
And an empty grid
83+
84+
When running osm2pgsql flex with parameters
85+
| --slim | -a |
86+
87+
Then table osm2pgsql_test_t1 contains exactly
88+
| way_id |
89+
Then table osm2pgsql_test_expire contains exactly
90+
| zoom | x | y |
91+
| 0 | 0 | 0 |
92+
93+
94+
Scenario: remove from t1
95+
Given the OSM data
96+
"""
97+
w11 v2 dD
98+
"""
99+
And an empty grid
100+
101+
When running osm2pgsql flex with parameters
102+
| --slim | -a |
103+
104+
Then table osm2pgsql_test_t1 contains exactly
105+
| way_id |
106+
Then table osm2pgsql_test_expire contains exactly
107+
| zoom | x | y |
108+
| 0 | 0 | 0 |

tests/bdd/flex/lua-expire.feature

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,26 @@ Feature: Expire configuration in Lua file
238238
Then table nodes has 1562 rows
239239
And table tiles has 0 rows
240240

241+
Scenario: Expire into table without maxzoom means maxzoom 0
242+
Given the input file 'liechtenstein-2013-08-03.osm.pbf'
243+
And the lua style
244+
"""
245+
local eo = osm2pgsql.define_expire_output({
246+
table = 'tiles',
247+
})
248+
local t = osm2pgsql.define_node_table('nodes', {
249+
{ column = 'geom',
250+
type = 'point',
251+
expire = {
252+
{ output = eo }
253+
}}
254+
})
255+
256+
function osm2pgsql.process_node(object)
257+
t:insert({ geom = object:as_point() })
258+
end
259+
"""
260+
When running osm2pgsql flex
261+
Then table nodes has 1562 rows
262+
And table tiles has 0 rows
263+

tests/data/test_expire.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
-- No maxzoom sets it to 0
3+
local eo = osm2pgsql.define_expire_output({
4+
table = 'osm2pgsql_test_expire',
5+
})
6+
7+
local the_table = osm2pgsql.define_way_table('osm2pgsql_test_t1', {
8+
{ column = 'tags', type = 'hstore' },
9+
{ column = 'geom', type = 'linestring', expire = {{ output = eo }} },
10+
})
11+
12+
function osm2pgsql.process_way(object)
13+
if object.tags.t1 then
14+
the_table:insert{
15+
tags = object.tags,
16+
geom = object:as_linestring()
17+
}
18+
end
19+
end
20+

0 commit comments

Comments
 (0)