Skip to content

Commit ff5369d

Browse files
committed
Add testing capability to pgsql capability code
And use it to test flex index setup.
1 parent 8de2822 commit ff5369d

File tree

4 files changed

+388
-18
lines changed

4 files changed

+388
-18
lines changed

src/pgsql-capabilities-int.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef OSM2PGSQL_PGSQL_CAPABILITIES_INT_HPP
2+
#define OSM2PGSQL_PGSQL_CAPABILITIES_INT_HPP
3+
4+
/**
5+
* SPDX-License-Identifier: GPL-2.0-or-later
6+
*
7+
* This file is part of osm2pgsql (https://osm2pgsql.org/).
8+
*
9+
* Copyright (C) 2006-2022 by the osm2pgsql developer community.
10+
* For a full list of authors see the git log.
11+
*/
12+
13+
#include "pgsql-capabilities.hpp"
14+
15+
#include <map>
16+
#include <set>
17+
#include <string>
18+
19+
struct database_capabilities_t
20+
{
21+
std::map<std::string, std::string> settings;
22+
23+
std::set<std::string> extensions;
24+
std::set<std::string> schemas;
25+
std::set<std::string> tablespaces;
26+
std::set<std::string> index_methods;
27+
28+
std::string database_name;
29+
30+
uint32_t database_version = 0;
31+
postgis_version postgis{};
32+
};
33+
34+
database_capabilities_t &database_capabilities_for_testing() noexcept;
35+
36+
#endif // OSM2PGSQL_PGSQL_CAPABILITIES_INT_HPP

src/pgsql-capabilities.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,23 @@
1010
#include "format.hpp"
1111
#include "logging.hpp"
1212
#include "pgsql-capabilities.hpp"
13+
#include "pgsql-capabilities-int.hpp"
1314
#include "pgsql.hpp"
1415
#include "version.hpp"
1516

16-
#include <map>
17-
#include <set>
1817
#include <stdexcept>
19-
#include <string>
20-
21-
struct database_capabilities_t
22-
{
23-
std::map<std::string, std::string> settings;
24-
25-
std::set<std::string> extensions;
26-
std::set<std::string> schemas;
27-
std::set<std::string> tablespaces;
28-
std::set<std::string> index_methods;
29-
30-
std::string database_name;
31-
32-
uint32_t database_version = 0;
33-
postgis_version postgis{};
34-
};
3518

3619
static database_capabilities_t &capabilities() noexcept
3720
{
3821
static database_capabilities_t c;
3922
return c;
4023
}
4124

25+
database_capabilities_t &database_capabilities_for_testing() noexcept
26+
{
27+
return capabilities();
28+
}
29+
4230
static void init_set_from_query(std::set<std::string> *set,
4331
pg_conn_t const &db_connection,
4432
char const *table, char const *column,

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ set_test(test-wkb LABELS NoDB)
8484

8585
# these tests require LUA support
8686
if (WITH_LUA)
87+
set_test(test-flex-indexes)
8788
set_test(test-output-flex)
8889
set_test(test-output-flex-multi-input)
8990
set_test(test-output-flex-nodes)

0 commit comments

Comments
 (0)