-
-
Notifications
You must be signed in to change notification settings - Fork 477
/
Copy pathtest-pgsql-capabilities.cpp
72 lines (59 loc) · 1.75 KB
/
test-pgsql-capabilities.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This file is part of osm2pgsql (https://osm2pgsql.org/).
*
* Copyright (C) 2006-2025 by the osm2pgsql developer community.
* For a full list of authors see the git log.
*/
#include <catch.hpp>
#include "common-import.hpp"
#include "pgsql-capabilities.hpp"
namespace {
testing::db::import_t db;
} // anonymous namespace
TEST_CASE("has_extension() should work")
{
init_database_capabilities(db.db().connect());
REQUIRE(has_extension("postgis"));
REQUIRE_FALSE(has_schema("xzxzxzxz"));
}
TEST_CASE("has_schema() should work")
{
init_database_capabilities(db.db().connect());
REQUIRE(has_schema("public"));
REQUIRE_FALSE(has_schema("xzxzxzxz"));
REQUIRE_FALSE(has_schema("pg_toast"));
}
TEST_CASE("has_tablespace() should work")
{
init_database_capabilities(db.db().connect());
REQUIRE(has_tablespace("pg_default"));
REQUIRE_FALSE(has_tablespace("xzxzxzxz"));
REQUIRE_FALSE(has_tablespace("pg_global"));
}
TEST_CASE("has_index_method() should work")
{
init_database_capabilities(db.db().connect());
REQUIRE(has_index_method("btree"));
REQUIRE_FALSE(has_index_method("xzxzxzxz"));
}
TEST_CASE("has_table() should work")
{
init_database_capabilities(db.db().connect());
REQUIRE_FALSE(has_table("public", "foo"));
REQUIRE_FALSE(has_table("someschema", "foo"));
REQUIRE(has_table("public", "spatial_ref_sys"));
}
TEST_CASE("PostgreSQL version")
{
init_database_capabilities(db.db().connect());
auto const version = get_database_version();
REQUIRE(version >= 9);
}
TEST_CASE("PostGIS version")
{
init_database_capabilities(db.db().connect());
auto const postgis_version = get_postgis_version();
REQUIRE(postgis_version.major >= 2);
}