blob: 8f07ceb6cb9b02c549ad75820ce4fbbeb8e74215 (
plain)
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
|
// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef TEST_PGSQL_SCHEMA_H
#define TEST_PGSQL_SCHEMA_H
#include <config.h>
#include <database/testutils/schema.h>
#include <string>
namespace isc {
namespace db {
namespace test {
extern const char* PGSQL_VALID_TYPE;
/// Return valid connection string
///
/// @return valid PgSQL connection string.
std::string validPgSQLConnectionString();
/// @brief Clear everything from the database
///
/// Submits the current schema drop script:
///
/// <TEST_ADMIN_SCRIPTS_DIR>/pgsql/dhcpdb_drop.pgsql
///
/// to the unit test Postgresql database. If the script fails, the invoking
/// test will fail. The output of stderr is suppressed unless the parameter,
/// show_err is true.
///
/// @param show_err flag which governs whether or not stderr is suppressed.
void destroyPgSQLSchema(bool show_err = false);
/// @brief Create the Postgresql Schema
///
/// Submits the current schema creation script:
///
/// <TEST_ADMIN_SCRIPTS_DIR>/pgsql/dhcpdb_create.pgsql
///
/// to the unit test Postgresql database. If the script fails, the invoking
/// test will fail. The output of stderr is suppressed unless the parameter,
/// show_err is true.
///
/// @param show_err flag which governs whether or not stderr is suppressed.
void createPgSQLSchema(bool show_err = false);
/// @brief Run a PgSQL SQL script against the Postgresql unit test database
///
/// Submits the given SQL script to Postgresql via psql CLI. The output of
/// stderr is suppressed unless the parameter, show_err is true. The is done
/// to suppress warnings that might otherwise make test output needlessly
/// noisy. A gtest assertion occurs if the script fails to execute.
///
/// @param path - path (if not blank) of the script to execute
/// @param script_name - file name of the path to execute
/// @param show_err flag which governs whether or not stderr is suppressed.
void runPgSQLScript(const std::string& path, const std::string& script_name,
bool show_err);
};
};
};
#endif
|