-
Notifications
You must be signed in to change notification settings - Fork 21
Refactor PgEmbed usage #384
Changes from all commits
5915429
8057ad0
1881db9
3193b04
bba3d22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,11 @@ use super::{ | |
| storage::Storage, AttachedConnector, ConfigDescr, ConfigId, ConnectorDescr, ConnectorId, | ||
| ConnectorType, PipelineId, ProjectDB, ProjectDescr, ProjectId, ProjectStatus, Version, | ||
| }; | ||
| use crate::db::DBError; | ||
| use crate::db::{pg_setup, DBError}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so or cargo test --no-default-features might fail? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the CI workflows to have feature=dev wherever --no-default-features is called. It's better to fail the run than to silently not run the tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it will result in a compilation error if you do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.g., |
||
| use anyhow::Result as AnyResult; | ||
| use async_trait::async_trait; | ||
| use chrono::DateTime; | ||
| use pg_embed::postgres::PgEmbed; | ||
| use pretty_assertions::assert_eq; | ||
| use proptest::prelude::*; | ||
| use proptest::test_runner::{Config, TestRunner}; | ||
|
|
@@ -20,6 +21,7 @@ use tokio::sync::Mutex; | |
|
|
||
| struct DbHandle { | ||
| db: ProjectDB, | ||
| pg: PgEmbed, | ||
| _temp_dir: TempDir, | ||
| } | ||
|
|
||
|
|
@@ -29,11 +31,9 @@ impl Drop for DbHandle { | |
| // shutdown postgres). Otherwise postgres log an error that the | ||
| // directory is already gone during shutdown which could be | ||
| // confusing for a developer. | ||
| if let Some(pg) = self.db.pg.as_mut() { | ||
| let _r = async { | ||
| pg.stop_db().await.unwrap(); | ||
| }; | ||
| } | ||
| let _r = async { | ||
| self.pg.stop_db().await.unwrap(); | ||
| }; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -55,19 +55,17 @@ async fn test_setup() -> DbHandle { | |
| .map(|l| l.port()) | ||
| .unwrap_or(DB_PORT_COUNTER.fetch_add(1, Ordering::Relaxed)) | ||
| }; | ||
| let pg = pg_setup::install(temp_path.into(), false, Some(port)) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| let conn = ProjectDB::connect_inner( | ||
| "postgres-embed", | ||
| &Some("".to_string()), | ||
| temp_path.into(), | ||
| false, | ||
| Some(port), | ||
| ) | ||
| .await | ||
| .unwrap(); | ||
| let conn = ProjectDB::connect_inner(&pg.db_uri, &Some("".to_string())) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| DbHandle { | ||
| db: conn, | ||
| pg: pg, | ||
| _temp_dir, | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be postgres:// now or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokio-postgres doesn't fill things in automatically, so "postgres://" does not work.