Skip to content

Commit

Permalink
formatter and added more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
olexiyb committed Jun 18, 2024
1 parent c290da9 commit 3a54550
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use sqlx_tokio::postgres::PgPoolOptions;

use pg_embed::pg_access::PgAccess;
use pg_embed::pg_enums::PgAuthMethod;
use pg_embed::pg_fetch::{PG_V16, PgFetchSettings};
use pg_embed::pg_fetch::{PgFetchSettings, PG_V16};
use pg_embed::postgres::{PgEmbed, PgSettings};

#[tokio::main]
Expand Down Expand Up @@ -58,7 +58,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
.connect(&pg.full_db_uri("database_name"))
.await?;

let row: (i64, ) = sqlx_tokio::query_as("SELECT $1")
let row: (i64,) = sqlx_tokio::query_as("SELECT $1")
.bind(150_i64)
.fetch_one(&pool)
.await?;
Expand Down
7 changes: 4 additions & 3 deletions src/command_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
///
fn new<A, B>(executable_path: &OsStr, args: A, process_type: P) -> Result<Self, E>
where
A: IntoIterator<Item = B>,
A: IntoIterator<Item=B>,
B: AsRef<OsStr>;
///
/// Execute command
Expand Down Expand Up @@ -113,11 +113,12 @@ where
/// Generate a command
fn generate_command<A, B>(executable_path: &OsStr, args: A) -> tokio::process::Command
where
A: IntoIterator<Item = B>,
A: IntoIterator<Item=B>,
B: AsRef<OsStr>,
{
let mut command = tokio::process::Command::new(executable_path);
command.args(args);
log::info!("command: {:?}", command);
#[cfg(target_os = "windows")]
{
const CREATE_NO_WINDOW: u32 = 0x08000000;
Expand Down Expand Up @@ -205,7 +206,7 @@ where
{
fn new<A, B>(executable_path: &OsStr, args: A, process_type: P) -> Result<Self, E>
where
A: IntoIterator<Item = B>,
A: IntoIterator<Item=B>,
B: AsRef<OsStr>,
{
let mut _command = Self::generate_command(executable_path, args);
Expand Down
15 changes: 6 additions & 9 deletions src/pg_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,12 @@ impl PgAccess {
format!("arch_{}", fetch_settings.operating_system)
}
};
let pg_path = format!(
"{}/{}/{}/{}",
PG_EMBED_CACHE_DIR_NAME,
os_string,
fetch_settings.architecture,
fetch_settings.version.0
);
let mut cache_pg_embed = cache_dir.clone();
cache_pg_embed.push(pg_path);
let cache_pg_embed = cache_dir
.clone()
.join(PG_EMBED_CACHE_DIR_NAME)
.join(os_string)
.join(fetch_settings.architecture.to_string())
.join(fetch_settings.version.0);
std::fs::create_dir_all(&cache_pg_embed).map_err(|e| PgEmbedError::DirCreationError {
dir: cache_pg_embed.clone(),
e,
Expand Down
2 changes: 1 addition & 1 deletion tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use env_logger::Env;

use pg_embed::pg_enums::PgAuthMethod;
use pg_embed::pg_errors::PgEmbedError;
use pg_embed::pg_fetch::{PG_V15, PgFetchSettings};
use pg_embed::pg_fetch::{PgFetchSettings, PG_V15};
use pg_embed::postgres::{PgEmbed, PgSettings};

pub async fn setup(
Expand Down
6 changes: 3 additions & 3 deletions tests/migration_tokio.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::path::PathBuf;

use serial_test::serial;
#[cfg(feature = "sqlx_tokio")]
use sqlx_tokio::{Connection, PgConnection};

use pg_embed::pg_errors::PgEmbedError;
#[cfg(feature = "sqlx_actix")]
use sqlx_actix::{Connection, PgConnection};
#[cfg(feature = "sqlx_async_std")]
use sqlx_async_std::{Connection, PgConnection};
#[cfg(feature = "sqlx_tokio")]
use sqlx_tokio::{Connection, PgConnection};

#[path = "common.rs"]
mod common;
Expand Down Expand Up @@ -49,7 +49,7 @@ async fn db_migration() -> Result<(), PgEmbedError> {
false,
Some(PathBuf::from("migration_test")),
)
.await?;
.await?;
pg.start_db().await?;
let db_name = "test";
pg.create_database(&db_name).await?;
Expand Down

0 comments on commit 3a54550

Please sign in to comment.