Skip to content

Commit 045bd90

Browse files
committed
introduce osm2pgsql-test-style for BDD testing
1 parent b9a86d0 commit 045bd90

33 files changed

+1313
-272
lines changed

scripts/osm2pgsql-test-style

Lines changed: 834 additions & 0 deletions
Large diffs are not rendered by default.

tests/bdd/command-line/invalid.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ Feature: Errors for invalid command line parameter combinations
77
"""
88

99
Scenario: create and append cannot be used together
10-
Then running osm2pgsql pgsql with parameters fails
10+
When running osm2pgsql pgsql with parameters
1111
| -c | -a |
12+
Then execution fails
1213
And the error output contains
1314
"""
1415
--append and --create options can not be used at the same time
1516
"""
1617

1718
Scenario: append can only be used with slim mode
18-
Then running osm2pgsql pgsql with parameters fails
19+
When running osm2pgsql pgsql with parameters
1920
| -a |
21+
Then execution fails
2022
And the error output contains
2123
"""
2224
--append can only be used with slim mode

tests/bdd/command-line/replication.feature

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,26 @@ Feature: Tests for the osm2pgsql-replication script with property table
4444
"""
4545
n34 Tamenity=restaurant x77 y45.3
4646
"""
47+
And the replication service at http://example.com/europe/liechtenstein-updates
4748
When running osm2pgsql pgsql with parameters
4849
| --slim |
4950

50-
Then running osm2pgsql-replication fails with returncode 1
51+
When running osm2pgsql-replication
5152
| init |
53+
Then execution fails with return code 1
5254
And the error output contains
5355
"""
5456
Cannot get timestamp from database.
5557
"""
5658

5759
Scenario: Replication cannot initialised on non-updatable database
5860
Given the input file 'liechtenstein-2013-08-03.osm.pbf'
61+
And the replication service at http://example.com/europe/liechtenstein-updates
5962
When running osm2pgsql pgsql
6063

61-
Then running osm2pgsql-replication fails with returncode 1
64+
When running osm2pgsql-replication
6265
| init |
66+
Then execution fails with return code 1
6367
And the error output contains
6468
"""
6569
Database needs to be imported in --slim mode.
@@ -130,8 +134,9 @@ Feature: Tests for the osm2pgsql-replication script with property table
130134
When running osm2pgsql pgsql with parameters
131135
| --slim |
132136

133-
Then running osm2pgsql-replication fails with returncode 1
137+
When running osm2pgsql-replication
134138
| init | --middle-schema=foobar |
139+
Then execution fails with return code 1
135140
And the error output contains
136141
"""
137142
Database needs to be imported in --slim mode.
@@ -275,8 +280,9 @@ Feature: Tests for the osm2pgsql-replication script with property table
275280
When running osm2pgsql pgsql with parameters
276281
| --slim |
277282

278-
Then running osm2pgsql-replication fails with returncode 1
283+
When running osm2pgsql-replication
279284
| update |
285+
Then execution fails with return code 1
280286
And the error output contains
281287
"""
282288
Updates not set up correctly.
@@ -354,8 +360,9 @@ Feature: Tests for the osm2pgsql-replication script with property table
354360
When running osm2pgsql pgsql with parameters
355361
| --slim |
356362

357-
Then running osm2pgsql-replication fails with returncode 2
363+
When running osm2pgsql-replication
358364
| status | --json |
365+
Then execution fails with return code 2
359366
And the standard output contains
360367
"""
361368
"status": 2
@@ -374,7 +381,8 @@ Feature: Tests for the osm2pgsql-replication script with property table
374381

375382
And running osm2pgsql-replication
376383
| status | --json |
377-
Then the standard output contains
384+
Then execution is successful
385+
And the standard output contains
378386
"""
379387
"status": 0
380388
"server": {"base_url": "http://example.com/europe/liechtenstein-updates", "sequence": 10000001, "timestamp": "2013-10-01T01:00:00Z"
@@ -391,8 +399,9 @@ Feature: Tests for the osm2pgsql-replication script with property table
391399
When running osm2pgsql pgsql with parameters
392400
| --slim |
393401

394-
Then running osm2pgsql-replication fails with returncode 1
402+
When running osm2pgsql-replication
395403
| init | --server | http://example.com/europe/liechtenstein-updates |
404+
Then execution fails with return code 1
396405
And the error output contains
397406
"""
398407
The replication service does not have diff files for the requested date.
@@ -408,8 +417,9 @@ Feature: Tests for the osm2pgsql-replication script with property table
408417
When running osm2pgsql pgsql with parameters
409418
| --slim |
410419

411-
Then running osm2pgsql-replication fails with returncode 1
420+
When running osm2pgsql-replication
412421
| init |
422+
Then execution fails with return code 1
413423
And the error output contains
414424
"""
415425
Cannot load state information for 9999999 from replication service http://example.com/europe/liechtenstein-updates.

tests/bdd/command-line/replication_legacy.feature

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ Feature: Tests for the osm2pgsql-replication script without property table
3030
| --slim |
3131
And deleting table osm2pgsql_properties
3232

33-
Then running osm2pgsql-replication fails with returncode 1
33+
When running osm2pgsql-replication
3434
| init | --osm-file={TEST_DATA_DIR}/008-ch.osc.gz |
35+
Then execution fails with return code 1
3536
And the error output contains
3637
"""
3738
has no usable replication headers
@@ -66,10 +67,11 @@ Feature: Tests for the osm2pgsql-replication script without property table
6667

6768
And deleting table foobar.osm2pgsql_properties
6869

69-
Then running osm2pgsql-replication fails with returncode 1
70+
When running osm2pgsql-replication
7071
| init |
7172
| --osm-file={TEST_DATA_DIR}/liechtenstein-2013-08-03.osm.pbf |
72-
And the error output contains
73+
Then execution fails with return code 1
74+
And the error output contains
7375
"""
7476
Database needs to be imported in --slim mode.
7577
"""
@@ -141,8 +143,9 @@ Feature: Tests for the osm2pgsql-replication script without property table
141143
When running osm2pgsql pgsql with parameters
142144
| --slim |
143145

144-
Then running osm2pgsql-replication fails with returncode 1
146+
When running osm2pgsql-replication
145147
| update |
148+
Then execution fails with return code 1
146149
And the error output contains
147150
"""
148151
Updates not set up correctly.
@@ -215,8 +218,9 @@ Feature: Tests for the osm2pgsql-replication script without property table
215218
| --slim |
216219
And deleting table osm2pgsql_properties
217220

218-
Then running osm2pgsql-replication fails with returncode 1
221+
When running osm2pgsql-replication
219222
| status | --json |
223+
Then execution fails with return code 1
220224
And the standard output contains
221225
"""
222226
"status": 1
@@ -238,7 +242,8 @@ Feature: Tests for the osm2pgsql-replication script without property table
238242

239243
And running osm2pgsql-replication
240244
| status | --json |
241-
Then the standard output contains
245+
Then execution is successful
246+
And the standard output contains
242247
"""
243248
"status": 0
244249
"server": {"base_url": "https://planet.openstreetmap.org/replication/minute", "sequence": 347, "timestamp": "2020-10-24T03:00:00Z"

tests/bdd/flex/area.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ Feature: Tests for area column type
4646
"""
4747
When running osm2pgsql flex
4848
Then table osm2pgsql_test_polygon contains
49-
| name | ST_Area(geom) | area | ST_Area(ST_Transform(geom, 4326)) |
50-
| poly | <st_area poly> | <area poly> | 0.01 |
51-
| multi | <st_area multi>| <area multi> | 0.08 |
49+
| name | ST_Area(geom)!~1% | area!~1% | ST_Area(ST_Transform(geom, 4326))!~0.01% |
50+
| poly | <st_area poly> | <area poly> | 0.01 |
51+
| multi | <st_area multi> | <area multi> | 0.08 |
5252

5353
Examples:
5454
| geom proj | area proj | st_area poly | area poly | st_area multi | area multi |

tests/bdd/flex/bbox.feature

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Feature: Test get_bbox() function
2929
When running osm2pgsql flex
3030

3131
Then table osm2pgsql_test_points contains exactly
32-
| node_id | min_x | max_x | min_y | max_y | ST_AsText(geom) |
33-
| 10 | 20.0 | 20.0 | 10.1 | 10.1 | <geometry> |
32+
| node_id | min_x | max_x | min_y | max_y | geom!geo |
33+
| 10 | 20.0 | 20.0 | 10.1 | 10.1 | <geometry> |
3434

3535
Examples:
3636
| projection | geometry |
@@ -39,8 +39,8 @@ Feature: Test get_bbox() function
3939

4040
Scenario Outline: for ways
4141
Given the 0.1 grid with origin 20.0 10.1
42-
| 10 | 11 |
4342
| | 12 |
43+
| 10 | 11 |
4444
And the OSM data
4545
"""
4646
w20 v1 dV Thighway=primary Nn10,n11,n12
@@ -69,8 +69,8 @@ Feature: Test get_bbox() function
6969
When running osm2pgsql flex
7070

7171
Then table osm2pgsql_test_highways contains exactly
72-
| way_id | min_x | max_x | min_y | max_y | ST_AsText(geom) |
73-
| 20 | 20.0 | 20.1 | 10.0 | 10.1 | <geometry> |
72+
| way_id | min_x | max_x | min_y | max_y | geom!geo |
73+
| 20 | 20.0 | 20.1 | 10.0 | 10.1 | <geometry> |
7474

7575
Examples:
7676
| projection | geometry |
@@ -79,8 +79,8 @@ Feature: Test get_bbox() function
7979

8080
Scenario Outline: for relations with way members only
8181
Given the 0.1 grid with origin 20.0 10.1
82-
| 10 | 11 |
8382
| | 12 |
83+
| 10 | 11 |
8484
And the OSM data
8585
"""
8686
w20 v1 dV Nn10,n11
@@ -115,9 +115,9 @@ Feature: Test get_bbox() function
115115
When running osm2pgsql flex
116116

117117
Then table osm2pgsql_test_routes contains exactly
118-
| relation_id | min_x | max_x | min_y | max_y | ST_AsText(geom) |
119-
| 30 | 20.0 | 20.1 | 10.1 | 10.1 | <geom30> |
120-
| 31 | 20.0 | 20.1 | 10.0 | 10.1 | <geom31> |
118+
| relation_id | min_x | max_x | min_y | max_y | geom!geo |
119+
| 30 | 20.0 | 20.1 | 10.1 | 10.1 | <geom30> |
120+
| 31 | 20.0 | 20.1 | 10.0 | 10.1 | <geom31> |
121121

122122
Examples:
123123
| projection | geom30 | geom31 |

tests/bdd/flex/delete-callbacks.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ Feature: Test for delete callbacks
2525
Then table change contains exactly
2626
| osm_type | osm_id |
2727

28-
Given the input file '008-ch.osc.gz'
29-
3028
Given the SQL statement grouped_counts
3129
"""
3230
SELECT osm_type,
@@ -38,6 +36,7 @@ Feature: Test for delete callbacks
3836
"""
3937

4038
Scenario: Delete callbacks are called
39+
Given the input file '008-ch.osc.gz'
4140
When running osm2pgsql flex with parameters
4241
| --slim | -a |
4342
Then statement grouped_counts returns exactly
@@ -46,6 +45,7 @@ Feature: Test for delete callbacks
4645
| W | 4 | 9 |
4746
| R | 1 | 3 |
4847

48+
Given the input file '008-ch.osc.gz'
4949
When running osm2pgsql flex with parameters
5050
| --slim | -a |
5151
Then statement grouped_counts returns exactly
@@ -78,6 +78,7 @@ Feature: Test for delete callbacks
7878
7979
8080
"""
81+
Given the input file '008-ch.osc.gz'
8182
When running osm2pgsql flex with parameters
8283
| --slim | -a |
8384
Then statement grouped_counts returns exactly
@@ -111,6 +112,7 @@ Feature: Test for delete callbacks
111112
112113
113114
"""
115+
Given the input file '008-ch.osc.gz'
114116
When running osm2pgsql flex with parameters
115117
| --slim | -a |
116118
Then statement grouped_counts returns exactly

tests/bdd/flex/empty-insert.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Feature: Tests that empty insert command does something
2020
end
2121
"""
2222

23-
Then running osm2pgsql flex fails
24-
23+
When running osm2pgsql flex
24+
Then execution fails
2525
And the error output contains
2626
"""
2727
Need two parameters

tests/bdd/flex/geometry-collection.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Feature: Create geometry collections from relations
4545
| 33 | node | ST_GeometryCollection | 1 | ST_Point |
4646

4747
And table osm2pgsql_test_collection contains exactly
48-
| osm_id | ST_AsText(geom) |
48+
| osm_id | geom!geo |
4949
| 30 | { 10, 11, 12, 13, 10 } |
5050
| 31 | { 10, 11, 12, 13, 10; 14, 15, 16 } |
5151
| 32 | { 17; 14, 15, 16 } |
@@ -105,6 +105,6 @@ Feature: Create geometry collections from relations
105105
When running osm2pgsql flex
106106

107107
Then table osm2pgsql_test_collection contains exactly
108-
| osm_id | name | ST_AsText(geom) |
108+
| osm_id | name | geom!geo |
109109
| 30 | three | { 10, 11, 12, 13, 10; 10, 11, 13 } |
110110

tests/bdd/flex/geometry-function-area.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Feature: Tests for area() function
4545
"""
4646
When running osm2pgsql flex
4747
Then table osm2pgsql_test_polygon contains
48-
| name | ST_Area(geom) | area | ST_Area(ST_Transform(geom, 4326)) |
49-
| poly | <st_area poly> | <area poly> | 0.01 |
50-
| multi | <st_area multi>| <area multi> | 0.08 |
48+
| name | ST_Area(geom)!~1% | area!~1% | ST_Area(ST_Transform(geom, 4326))!~1% |
49+
| poly | <st_area poly> | <area poly> | 0.01 |
50+
| multi | <st_area multi> | <area multi> | 0.08 |
5151

5252
Examples:
5353
| geom proj | area proj | st_area poly | area poly | st_area multi | area multi |

0 commit comments

Comments
 (0)