(settings: PostgresStoreSettings)
| 160 | } |
| 161 | |
| 162 | pub async fn new_with_settings(settings: PostgresStoreSettings) -> Self { |
| 163 | load_env(Environment::Test); |
| 164 | init_logging(); |
| 165 | |
| 166 | let user = std::env::var("HASH_GRAPH_PG_USER").unwrap_or_else(|_| "graph".to_owned()); |
| 167 | let password = |
| 168 | std::env::var("HASH_GRAPH_PG_PASSWORD").unwrap_or_else(|_| "graph".to_owned()); |
| 169 | let host = std::env::var("HASH_GRAPH_PG_HOST").unwrap_or_else(|_| "localhost".to_owned()); |
| 170 | let port = |
| 171 | std::env::var("HASH_GRAPH_PG_PORT").map_or(5432, |port| port.parse::<u16>().unwrap()); |
| 172 | let database = |
| 173 | std::env::var("HASH_GRAPH_PG_DATABASE").unwrap_or_else(|_| "graph".to_owned()); |
| 174 | |
| 175 | let connection_info = DatabaseConnectionInfo::new( |
| 176 | DatabaseType::Postgres, |
| 177 | user, |
| 178 | password, |
| 179 | host, |
| 180 | port, |
| 181 | database, |
| 182 | ); |
| 183 | |
| 184 | let pool = PostgresStorePool::new( |
| 185 | &connection_info, |
| 186 | &DatabasePoolConfig::default(), |
| 187 | NoTls, |
| 188 | settings, |
| 189 | ) |
| 190 | .await |
| 191 | .expect("could not connect to database"); |
| 192 | |
| 193 | let connection = pool |
| 194 | .acquire_owned(None) |
| 195 | .await |
| 196 | .expect("could not acquire a database connection"); |
| 197 | |
| 198 | Self { |
| 199 | _pool: pool, |
| 200 | connection, |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | impl DatabaseTestWrapper { |
nothing calls this directly
no test coverage detected