(
bench_db_name: &str,
fail_on_exists: bool,
delete_on_drop: bool,
account_id: ActorEntityUuid,
)
| 68 | impl StoreWrapper { |
| 69 | #[expect(clippy::too_many_lines)] |
| 70 | pub async fn new( |
| 71 | bench_db_name: &str, |
| 72 | fail_on_exists: bool, |
| 73 | delete_on_drop: bool, |
| 74 | account_id: ActorEntityUuid, |
| 75 | ) -> Self { |
| 76 | load_env(Environment::Test); |
| 77 | |
| 78 | let super_user = std::env::var("POSTGRES_USER").unwrap_or_else(|_| "postgres".to_owned()); |
| 79 | let super_password = |
| 80 | std::env::var("POSTGRES_PASSWORD").unwrap_or_else(|_| "postgres".to_owned()); |
| 81 | |
| 82 | let user = std::env::var("HASH_GRAPH_PG_USER").unwrap_or_else(|_| "graph".to_owned()); |
| 83 | let password = |
| 84 | std::env::var("HASH_GRAPH_PG_PASSWORD").unwrap_or_else(|_| "graph".to_owned()); |
| 85 | let host = std::env::var("HASH_GRAPH_PG_HOST").unwrap_or_else(|_| "localhost".to_owned()); |
| 86 | let port = std::env::var("HASH_GRAPH_PG_PORT").map_or(5432, |port| { |
| 87 | port.parse::<u16>() |
| 88 | .unwrap_or_else(|_| panic!("{port} is not a valid port")) |
| 89 | }); |
| 90 | let database = |
| 91 | std::env::var("HASH_GRAPH_PG_DATABASE").unwrap_or_else(|_| "graph".to_owned()); |
| 92 | |
| 93 | let source_db_connection_info = DatabaseConnectionInfo::new( |
| 94 | DatabaseType::Postgres, |
| 95 | super_user.clone(), // super user as we need to create and delete tables |
| 96 | super_password.clone(), |
| 97 | host.clone(), |
| 98 | port, |
| 99 | database, |
| 100 | ); |
| 101 | |
| 102 | let bench_db_connection_info = DatabaseConnectionInfo::new( |
| 103 | DatabaseType::Postgres, |
| 104 | user, |
| 105 | password, |
| 106 | host.clone(), |
| 107 | port, |
| 108 | bench_db_name.to_owned(), |
| 109 | ); |
| 110 | |
| 111 | let source_db_pool = PostgresStorePool::new( |
| 112 | &source_db_connection_info, |
| 113 | &DatabasePoolConfig::default(), |
| 114 | NoTls, |
| 115 | PostgresStoreSettings::default(), |
| 116 | ) |
| 117 | .await |
| 118 | .expect("could not connect to database"); |
| 119 | |
| 120 | // Create a new connection to the source database, copy the database, drop the connection |
| 121 | { |
| 122 | let conn = source_db_pool |
| 123 | .acquire_owned(None) |
| 124 | .await |
| 125 | .expect("could not acquire a database connection"); |
| 126 | let client = conn.as_client(); |
| 127 |
nothing calls this directly
no test coverage detected