Skip to content

Commit 4385d22

Browse files
committed
Move common pg testing code into "testing" namespace
This is more consistent with the other testing code which is also in this namespace.
1 parent c7ab81c commit 4385d22

9 files changed

+31
-26
lines changed

tests/common-import.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ class import_t
216216
{out_test}, file);
217217
}
218218

219-
pg::conn_t connect() { return m_db.connect(); }
219+
testing::pg::conn_t connect() { return m_db.connect(); }
220220

221-
pg::tempdb_t const &db() const { return m_db; }
221+
testing::pg::tempdb_t const &db() const { return m_db; }
222222

223223
private:
224-
pg::tempdb_t m_db;
224+
testing::pg::tempdb_t m_db;
225225
};
226226

227227
} // namespace db

tests/common-options.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class opt_t
2828
return *this;
2929
}
3030

31-
opt_t &slim(pg::tempdb_t const &db)
31+
opt_t &slim(testing::pg::tempdb_t const &db)
3232
{
3333
m_opt.slim = true;
3434
m_opt.database_options = db.db_options();

tests/common-pg.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define getpid _getpid
2020
#endif
2121

22+
namespace testing {
2223
/// Helper classes for postgres connections
2324
namespace pg {
2425

@@ -141,5 +142,6 @@ class tempdb_t
141142
};
142143

143144
} // namespace pg
145+
} // namespace testing
144146

145147
#endif // OSM2PGSQL_TEST_COMMON_PG_HPP

tests/test-db-copy-mgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "common-pg.hpp"
88
#include "db-copy-mgr.hpp"
99

10-
static pg::tempdb_t db;
10+
static testing::pg::tempdb_t db;
1111

1212
using copy_mgr_t = db_copy_mgr_t<db_deleter_by_id_t>;
1313

tests/test-db-copy-thread.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#include "db-copy.hpp"
55
#include "gazetteer-style.hpp"
66

7-
static pg::tempdb_t db;
7+
static testing::pg::tempdb_t db;
88

9-
static int table_count(pg::conn_t const &conn, std::string const &where = "")
9+
static int table_count(testing::pg::conn_t const &conn,
10+
std::string const &where = "")
1011
{
1112
return conn.require_scalar<int>("SELECT count(*) FROM test_copy_thread " +
1213
where);

tests/test-middle.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <algorithm>
1515

16-
static pg::tempdb_t db;
16+
static testing::pg::tempdb_t db;
1717

1818
namespace {
1919

@@ -106,15 +106,15 @@ void expect_location(osmium::Location loc, osmium::Node const &expected)
106106

107107
struct options_slim_default
108108
{
109-
static options_t options(pg::tempdb_t const &tmpdb)
109+
static options_t options(testing::pg::tempdb_t const &tmpdb)
110110
{
111111
return testing::opt_t().slim(tmpdb);
112112
}
113113
};
114114

115115
struct options_slim_with_schema
116116
{
117-
static options_t options(pg::tempdb_t const &tmpdb)
117+
static options_t options(testing::pg::tempdb_t const &tmpdb)
118118
{
119119
options_t o = testing::opt_t().slim(tmpdb);
120120
o.middle_dbschema = "osm";
@@ -124,7 +124,7 @@ struct options_slim_with_schema
124124

125125
struct options_slim_dense_cache
126126
{
127-
static options_t options(pg::tempdb_t const &tmpdb)
127+
static options_t options(testing::pg::tempdb_t const &tmpdb)
128128
{
129129
options_t o = options_slim_default::options(tmpdb);
130130
o.alloc_chunkwise = ALLOC_DENSE;
@@ -134,15 +134,15 @@ struct options_slim_dense_cache
134134

135135
struct options_flat_node_cache
136136
{
137-
static options_t options(pg::tempdb_t const &tmpdb)
137+
static options_t options(testing::pg::tempdb_t const &tmpdb)
138138
{
139139
return testing::opt_t().slim(tmpdb).flatnodes();
140140
}
141141
};
142142

143143
struct options_ram_optimized
144144
{
145-
static options_t options(pg::tempdb_t const &)
145+
static options_t options(testing::pg::tempdb_t const &)
146146
{
147147
options_t o = testing::opt_t();
148148
o.alloc_chunkwise = ALLOC_SPARSE | ALLOC_DENSE;
@@ -152,7 +152,7 @@ struct options_ram_optimized
152152

153153
struct options_ram_flatnode
154154
{
155-
static options_t options(pg::tempdb_t const &)
155+
static options_t options(testing::pg::tempdb_t const &)
156156
{
157157
options_t o = testing::opt_t().flatnodes();
158158
o.alloc_chunkwise = ALLOC_SPARSE | ALLOC_DENSE;

tests/test-output-gazetteer.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ class gazetteer_fixture_t
191191
REQUIRE_NOTHROW(db.run_import(opt, opl.c_str()));
192192
}
193193

194-
unsigned long obj_count(pg::conn_t const &conn, osmid_t id, char const *cls)
194+
unsigned long obj_count(testing::pg::conn_t const &conn, osmid_t id,
195+
char const *cls)
195196
{
196197
char const tchar = m_opl_factory.type();
197198
return conn.get_count("place",
@@ -200,26 +201,26 @@ class gazetteer_fixture_t
200201
"AND class = '{}'"_format(tchar, id, cls));
201202
}
202203

203-
void obj_names(pg::conn_t const &conn, osmid_t id, char const *cls,
204+
void obj_names(testing::pg::conn_t const &conn, osmid_t id, char const *cls,
204205
hstore_list const &names)
205206
{
206207
hstore_compare(conn, id, cls, "name", names);
207208
}
208209

209-
void obj_address(pg::conn_t const &conn, osmid_t id, char const *cls,
210-
hstore_list const &names)
210+
void obj_address(testing::pg::conn_t const &conn, osmid_t id,
211+
char const *cls, hstore_list const &names)
211212
{
212213
hstore_compare(conn, id, cls, "address", names);
213214
}
214215

215-
void obj_extratags(pg::conn_t const &conn, osmid_t id, char const *cls,
216-
hstore_list const &names)
216+
void obj_extratags(testing::pg::conn_t const &conn, osmid_t id,
217+
char const *cls, hstore_list const &names)
217218
{
218219
hstore_compare(conn, id, cls, "extratags", names);
219220
}
220221

221-
std::string obj_field(pg::conn_t const &conn, osmid_t id, char const *cls,
222-
char const *column)
222+
std::string obj_field(testing::pg::conn_t const &conn, osmid_t id,
223+
char const *cls, char const *column)
223224
{
224225
char const tchar = m_opl_factory.type();
225226
return conn.require_scalar<std::string>(
@@ -228,8 +229,9 @@ class gazetteer_fixture_t
228229
}
229230

230231
private:
231-
void hstore_compare(pg::conn_t const &conn, osmid_t id, char const *cls,
232-
char const *column, hstore_list const &names)
232+
void hstore_compare(testing::pg::conn_t const &conn, osmid_t id,
233+
char const *cls, char const *column,
234+
hstore_list const &names)
233235
{
234236
char const tchar = m_opl_factory.type();
235237
auto const sql =

tests/test-output-pgsql-tablespace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
static testing::db::import_t db;
77

8-
static void require_tables(pg::conn_t const &conn)
8+
static void require_tables(testing::pg::conn_t const &conn)
99
{
1010
conn.require_has_table("osm2pgsql_test_point");
1111
conn.require_has_table("osm2pgsql_test_line");

tests/test-output-pgsql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
static testing::db::import_t db;
77

8-
static void require_tables(pg::conn_t const &conn)
8+
static void require_tables(testing::pg::conn_t const &conn)
99
{
1010
conn.require_has_table("osm2pgsql_test_point");
1111
conn.require_has_table("osm2pgsql_test_line");

0 commit comments

Comments
 (0)