ORE Studio 0.0.4
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
test_database_manager Class Reference

Manages isolated test databases for parallel test execution. More...

#include <test_database_manager.hpp>

Collaboration diagram for test_database_manager:
Collaboration graph

Static Public Member Functions

static database::context make_context ()
 Creates a database context from environment variables.
 
static database::database_options make_database_options ()
 Creates database options from environment variables.
 
static std::string generate_test_database_name ()
 Generates a unique database name for this test process.
 
static void create_test_database (const std::string &db_name)
 Creates a test database from the oresdb_template.
 
static void drop_test_database (const std::string &db_name)
 Drops the test database.
 
static void set_test_database_env (const std::string &db_name)
 Sets the TEST_ORES_DB_DATABASE environment variable.
 

Detailed Description

Manages isolated test databases for parallel test execution.

This class provides utilities for creating and destroying unique test databases for each test process. This allows multiple test processes to run concurrently without interference.

Each test database is created from the oresdb_template database, which must be pre-configured with the full schema.

Member Function Documentation

◆ generate_test_database_name()

std::string generate_test_database_name ( )
static

Generates a unique database name for this test process.

The database name is based on the process ID and a random suffix to ensure uniqueness: oresdb_test_{pid}_{random}

Returns
A unique database name string
Here is the caller graph for this function:

◆ create_test_database()

void create_test_database ( const std::string &  db_name)
static

Creates a test database from the oresdb_template.

This method connects to the postgres database (admin database) and executes CREATE DATABASE with the template parameter.

Parameters
db_nameThe name of the database to create
Exceptions
std::runtime_errorif database creation fails
Here is the caller graph for this function:

◆ drop_test_database()

void drop_test_database ( const std::string &  db_name)
static

Drops the test database.

This method connects to the postgres database and executes DROP DATABASE. It terminates any active connections first.

Parameters
db_nameThe name of the database to drop
Here is the caller graph for this function:

◆ set_test_database_env()

void set_test_database_env ( const std::string &  db_name)
static

Sets the TEST_ORES_DB_DATABASE environment variable.

This ensures that database_fixture and all tests use the isolated test database.

Parameters
db_nameThe database name to set
Here is the caller graph for this function: