Files
foxhunt/testing/e2e/src/database.rs
jgrusewski 9c3d741a08 refactor: restructure repo — crates/, bin/, testing/ layout
Move 17 library crates into crates/, CLI binary into bin/fxt,
consolidate 10 test crates into testing/, split config crate
from deployment config files.

Root directory reduced from 38+ to ~17 directories.
All Cargo.toml paths and build.rs proto refs updated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 11:56:00 +01:00

64 lines
1.3 KiB
Rust

//! Database utilities for e2e testing
use anyhow::Result;
use sqlx::PgPool;
use std::sync::Arc;
/// Test database utilities
#[derive(Debug, Clone)]
pub struct TestDatabase {
pub connection_string: String,
}
impl TestDatabase {
pub fn new(connection_string: String) -> Self {
Self { connection_string }
}
pub async fn setup(&self) -> Result<()> {
Ok(())
}
pub async fn teardown(&self) -> Result<()> {
Ok(())
}
}
/// Database test harness for e2e testing
#[derive(Debug, Clone)]
pub struct DatabaseTestHarness {
pool: Arc<PgPool>,
}
impl DatabaseTestHarness {
/// Create a new database test harness
pub fn new(pool: PgPool) -> Self {
Self {
pool: Arc::new(pool),
}
}
/// Get a reference to the database pool
pub fn pool(&self) -> &PgPool {
&self.pool
}
/// Setup test data
pub async fn setup_test_data(&self) -> Result<()> {
// Implementation for setting up test data
Ok(())
}
/// Clean up test data
pub async fn cleanup_test_data(&self) -> Result<()> {
// Implementation for cleaning up test data
Ok(())
}
/// Execute a raw SQL query for testing
pub async fn execute_sql(&self, sql: &str) -> Result<()> {
sqlx::query(sql).execute(&*self.pool).await?;
Ok(())
}
}