Skip to content

Commit a3ca6aa

Browse files
committed
sentry - db - postgres test pool fix
1 parent 1016db1 commit a3ca6aa

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

docker-compose.harness.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ version: '3.8'
33
services:
44
adex-postgres:
55
build: ./scripts/postgres
6-
# image: adex-postges
6+
image: adex-postgres
77
container_name: adex-postgres
88
restart: always
9-
# volumes:
10-
# - ./scripts/postgres:/docker-entrypoint-initdb.d
119
ports:
1210
- "5432:5432"
1311
environment:

sentry/src/db.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,18 @@ pub mod tests_postgres {
329329
// DROP the public schema and create it again for usage after recycling
330330
let queries = "DROP SCHEMA public CASCADE; CREATE SCHEMA public;";
331331

332-
let database_client = database.pool.get().await.map_err(|err| {
333-
match &err {
334-
PoolError::Backend(backend_err) if backend_err.is_closed() => {
335-
panic!("Closed PG Client connection of the database {} Pool!", database.name);
336-
}
337-
_ => {}
338-
}
339-
err
340-
})?;
341-
342-
let result = database_client
332+
database.pool = {
333+
let mut config = self.base_config.clone();
334+
// set the database in the configuration of the inside Pool (used for tests)
335+
config.dbname(&database.name);
336+
337+
let manager =
338+
deadpool_postgres::Manager::from_config(config, NoTls, self.manager_config.clone());
339+
340+
deadpool_postgres::Pool::new(manager, 15)
341+
};
342+
343+
let result = pool.get().await?
343344
.simple_query(queries)
344345
.await
345346
.map_err(PoolError::Backend)

0 commit comments

Comments
 (0)