ORE Studio 0.0.4
Loading...
Searching...
No Matches
scoped_database_helper.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_TESTING_SCOPED_DATABASE_HELPER_HPP
21#define ORES_TESTING_SCOPED_DATABASE_HELPER_HPP
22
23#include <string>
24#include "ores.testing/database_helper.hpp"
25
26namespace ores::testing {
27
32public:
33 explicit scoped_database_helper(const std::string& table_name) {
34 helper_.truncate_table(table_name);
35 }
36
40 database::context& context() { return helper_.context(); }
41
42private:
43 database_helper helper_;
44};
45
46}
47
48#endif
Testing infrastructure common to all test projects.
Definition database_helper.hpp:27
Context for the operations on a postgres database.
Definition context.hpp:30
Provides database setup and cleanup utilities for tests.
Definition database_helper.hpp:32
database::context & context()
Gets the database context.
Definition database_helper.hpp:56
void truncate_table(const std::string &table_name)
Truncates the specified table.
Definition database_helper.cpp:32
Provides database setup and cleanup utilities for tests.
Definition scoped_database_helper.hpp:31
database::context & context()
Gets the database context.
Definition scoped_database_helper.hpp:40