pgLab/tests/pgintegration/DbTest.h
2026-10-18 12:32:16 +02:00

28 lines
684 B
C++

#pragma once
#include <gtest/gtest.h>
#include <memory>
#include <QString>
#include "Pgsql_Connection.h"
namespace pgtest {
/// Fixture giving every test its own database cloned from the template.
class DbTest : public ::testing::Test {
protected:
void SetUp() override;
void TearDown() override;
Pgsql::Connection& conn() { return *conn_; }
QString dbName() const { return dbName_; }
QString dbUrl() const;
/// Opens a new connection to this test's database as the plain (non-superuser) role.
std::unique_ptr<Pgsql::Connection> plainConn() const;
private:
QString dbName_;
std::unique_ptr<Pgsql::Connection> conn_;
};
} // namespace pgtest