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
73
74
75
76
77
78
79
80
// Copyright (C) 2021-2022 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/.

#include <config.h>

#include <dhcpsrv/testutils/pgsql_generic_backend_unittest.h>
#include <pgsql/testutils/pgsql_schema.h>
#include <testutils/gtest_utils.h>

#include <gtest/gtest.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <pgsql_cb_impl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

using namespace isc::db;
using namespace isc::dhcp;
using namespace isc::dhcp::test;
using namespace isc::util;

namespace {

class PgSqlConfigBackendTest : public PgSqlGenericBackendTest {
public:
    PgSqlConfigBackendTest() : PgSqlGenericBackendTest() {
        createFullSchema();
    }

    /// @brief Setup for each test.
    ///
    /// Creates the configuration backend impl.
    virtual void SetUp() {
        DatabaseConnection::ParameterMap params;
        params["name"] = "keatest";
        params["password"] = "keatest";
        params["user"] = "keatest";
        ASSERT_NO_THROW_LOG(cbptr_.reset(new PgSqlConfigBackendImpl("", params, 0, 0)));
    }

    /// @brief Cleans up after each test.
    ///
    /// Destroys the configuration backend impl.
    virtual void TearDown() {
        ASSERT_NO_THROW_LOG(cbptr_.reset());
    }

    ~PgSqlConfigBackendTest() {
        destroyFullSchema();
    }

    /// @brief creates full schema (slow!)
    ///
    /// If possible, use simpler, faster alternative: @ref createDummySchema();
    /// Don't forget to tear it down with @ref destroyFullSchema();
    void createFullSchema() {
        // Create the actual full Kea schema.
        isc::db::test::createPgSQLSchema();
    }

    /// @brief destroys the full schema (slow!)
    ///
    /// Don't forget to call this method once you're done, if you used @ref createFullSchema().
    void destroyFullSchema() {
        // Clean up after ourselves.
        isc::db::test::destroyPgSQLSchema();
    }

    boost::shared_ptr<PgSqlConfigBackendImpl> cbptr_;
};

// Let's start with absolute basics.  This should construct a backend instance
// connected to the unit test schema.  The backend instance is created in
// Setup() and which will ASSERT on failures.
TEST_F(PgSqlConfigBackendTest, constructor) {<--- syntax error
    //  Is this the right config backend type?
    EXPECT_EQ("postgresql", cbptr_->getType());
}

}  // namespace