|
5 | 5 |
|
6 | 6 | static testing::db::import_t db; |
7 | 7 |
|
8 | | -TEST_CASE("no extra_attributes") |
| 8 | +static char const *const conf_file = "test_output_flex_attr.lua"; |
| 9 | +static char const *const table = "osm2pgsql_test_attr"; |
| 10 | + |
| 11 | +TEST_CASE("without extra_attributes") |
9 | 12 | { |
| 13 | + options_t options = testing::opt_t().slim().flex(conf_file); |
| 14 | + |
10 | 15 | REQUIRE_NOTHROW( |
11 | | - db.run_import(testing::opt_t().slim().flex("test_output_flex_attr.lua"), |
12 | | - "n10 v1 dV x10.0 y10.0\n" |
13 | | - "n11 v1 dV x10.0 y10.2\n" |
14 | | - "n12 v1 dV x10.2 y10.2\n" |
15 | | - "w20 v1 dV c31 t2020-01-12T12:34:56Z i17 utest " |
16 | | - "Thighway=primary Nn10,n11,n12\n")); |
| 16 | + db.run_import(options, "n10 v1 dV x10.0 y10.0\n" |
| 17 | + "n11 v1 dV x10.0 y10.2\n" |
| 18 | + "n12 v1 dV x10.2 y10.2\n" |
| 19 | + "w20 v1 dV c31 t2020-01-12T12:34:56Z i17 utest " |
| 20 | + "Thighway=primary Nn10,n11,n12\n")); |
17 | 21 |
|
18 | 22 | auto conn = db.db().connect(); |
19 | 23 |
|
20 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr")); |
21 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", |
22 | | - "tags->'highway' = 'primary'")); |
23 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "version = 1")); |
24 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "changeset = 31")); |
25 | | - CHECK(0 == |
26 | | - conn.get_count("osm2pgsql_test_ways_attr", "timestamp = 1578832496")); |
27 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "uid = 17")); |
28 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "\"user\" = 'test'")); |
29 | | - |
30 | | - REQUIRE_NOTHROW(db.run_import( |
31 | | - testing::opt_t().slim().append().flex("test_output_flex_attr.lua"), |
32 | | - "n10 v2 dV x11.0 y11.0\n")); |
33 | | - |
34 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr")); |
35 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", |
36 | | - "tags->'highway' = 'primary'")); |
37 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "version = 1")); |
38 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "changeset = 31")); |
39 | | - CHECK(0 == |
40 | | - conn.get_count("osm2pgsql_test_ways_attr", "timestamp = 1578832496")); |
41 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "uid = 17")); |
42 | | - CHECK(0 == conn.get_count("osm2pgsql_test_ways_attr", "\"user\" = 'test'")); |
| 24 | + CHECK(1 == conn.get_count(table)); |
| 25 | + CHECK(1 == conn.get_count(table, "tags->'highway' = 'primary'")); |
| 26 | + CHECK(0 == conn.get_count(table, "version = 1")); |
| 27 | + CHECK(0 == conn.get_count(table, "changeset = 31")); |
| 28 | + CHECK(0 == conn.get_count(table, "timestamp = 1578832496")); |
| 29 | + CHECK(0 == conn.get_count(table, "uid = 17")); |
| 30 | + CHECK(0 == conn.get_count(table, "\"user\" = 'test'")); |
| 31 | + |
| 32 | + options.append = true; |
| 33 | + |
| 34 | + REQUIRE_NOTHROW(db.run_import(options, "n10 v2 dV x11.0 y11.0\n")); |
| 35 | + |
| 36 | + CHECK(1 == conn.get_count(table)); |
| 37 | + CHECK(1 == conn.get_count(table, "tags->'highway' = 'primary'")); |
| 38 | + CHECK(0 == conn.get_count(table, "version = 1")); |
| 39 | + CHECK(0 == conn.get_count(table, "changeset = 31")); |
| 40 | + CHECK(0 == conn.get_count(table, "timestamp = 1578832496")); |
| 41 | + CHECK(0 == conn.get_count(table, "uid = 17")); |
| 42 | + CHECK(0 == conn.get_count(table, "\"user\" = 'test'")); |
43 | 43 | } |
44 | 44 |
|
45 | 45 | TEST_CASE("with extra_attributes") |
46 | 46 | { |
| 47 | + options_t options = |
| 48 | + testing::opt_t().extra_attributes().slim().flex(conf_file); |
| 49 | + |
47 | 50 | REQUIRE_NOTHROW( |
48 | | - db.run_import(testing::opt_t().extra_attributes().slim().flex( |
49 | | - "test_output_flex_attr.lua"), |
50 | | - "n10 v1 dV x10.0 y10.0\n" |
51 | | - "n11 v1 dV x10.0 y10.2\n" |
52 | | - "n12 v1 dV x10.2 y10.2\n" |
53 | | - "w20 v1 dV c31 t2020-01-12T12:34:56Z i17 utest " |
54 | | - "Thighway=primary Nn10,n11,n12\n")); |
| 51 | + db.run_import(options, "n10 v1 dV x10.0 y10.0\n" |
| 52 | + "n11 v1 dV x10.0 y10.2\n" |
| 53 | + "n12 v1 dV x10.2 y10.2\n" |
| 54 | + "w20 v1 dV c31 t2020-01-12T12:34:56Z i17 utest " |
| 55 | + "Thighway=primary Nn10,n11,n12\n")); |
55 | 56 |
|
56 | 57 | auto conn = db.db().connect(); |
57 | 58 |
|
58 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr")); |
59 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", |
60 | | - "tags->'highway' = 'primary'")); |
61 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "version = 1")); |
62 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "changeset = 31")); |
63 | | - CHECK(1 == |
64 | | - conn.get_count("osm2pgsql_test_ways_attr", "timestamp = 1578832496")); |
65 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "uid = 17")); |
66 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "\"user\" = 'test'")); |
| 59 | + CHECK(1 == conn.get_count(table)); |
| 60 | + CHECK(1 == conn.get_count(table, "tags->'highway' = 'primary'")); |
| 61 | + CHECK(1 == conn.get_count(table, "version = 1")); |
| 62 | + CHECK(1 == conn.get_count(table, "changeset = 31")); |
| 63 | + CHECK(1 == conn.get_count(table, "timestamp = 1578832496")); |
| 64 | + CHECK(1 == conn.get_count(table, "uid = 17")); |
| 65 | + CHECK(1 == conn.get_count(table, "\"user\" = 'test'")); |
67 | 66 |
|
68 | | - REQUIRE_NOTHROW( |
69 | | - db.run_import(testing::opt_t().extra_attributes().slim().append().flex( |
70 | | - "test_output_flex_attr.lua"), |
71 | | - "n10 v2 dV x11.0 y11.0\n")); |
72 | | - |
73 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr")); |
74 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", |
75 | | - "tags->'highway' = 'primary'")); |
76 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "version = 1")); |
77 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "changeset = 31")); |
78 | | - CHECK(1 == |
79 | | - conn.get_count("osm2pgsql_test_ways_attr", "timestamp = 1578832496")); |
80 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "uid = 17")); |
81 | | - CHECK(1 == conn.get_count("osm2pgsql_test_ways_attr", "\"user\" = 'test'")); |
| 67 | + options.append = true; |
| 68 | + |
| 69 | + REQUIRE_NOTHROW(db.run_import(options, "n10 v2 dV x11.0 y11.0\n")); |
| 70 | + |
| 71 | + CHECK(1 == conn.get_count(table)); |
| 72 | + CHECK(1 == conn.get_count(table, "tags->'highway' = 'primary'")); |
| 73 | + CHECK(1 == conn.get_count(table, "version = 1")); |
| 74 | + CHECK(1 == conn.get_count(table, "changeset = 31")); |
| 75 | + CHECK(1 == conn.get_count(table, "timestamp = 1578832496")); |
| 76 | + CHECK(1 == conn.get_count(table, "uid = 17")); |
| 77 | + CHECK(1 == conn.get_count(table, "\"user\" = 'test'")); |
82 | 78 | } |
0 commit comments