From 936c72b8b94cfa8f2d6f5e4f636446c28bcc5832 Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 15:31:05 -0600 Subject: [PATCH 01/11] fix: correct bug where commands hang on windows when retrieving stdout/stderr --- .github/workflows/ci.yml | 6 +- postgresql_commands/src/traits.rs | 128 ++++++++---------------------- 2 files changed, 37 insertions(+), 97 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0acb582..daafaff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - linux-x64 - macos-arm64 - macos-x64 - #- windows-x64 + - windows-x64 include: - platform: linux-x64 @@ -36,8 +36,8 @@ jobs: os: macos-14 - platform: macos-x64 os: macos-13 - #- platform: windows-x64 - # os: windows-2022 + - platform: windows-x64 + os: windows-2022 steps: - name: Checkout source code diff --git a/postgresql_commands/src/traits.rs b/postgresql_commands/src/traits.rs index b595e5e..c1c9014 100644 --- a/postgresql_commands/src/traits.rs +++ b/postgresql_commands/src/traits.rs @@ -141,8 +141,17 @@ impl CommandExecutor for std::process::Command { fn execute(&mut self) -> Result<(String, String)> { debug!("Executing command: {}", self.to_command_string()); let output = self.output()?; + + #[cfg(not(target_os = "windows"))] let stdout = String::from_utf8_lossy(&output.stdout).into_owned(); + #[cfg(target_os = "windows")] + let stdout = String::new(); + + #[cfg(not(target_os = "windows"))] let stderr = String::from_utf8_lossy(&output.stderr).into_owned(); + #[cfg(target_os = "windows")] + let stderr = String::new(); + debug!( "Result: {}\nstdout: {}\nstderr: {}", output @@ -163,111 +172,42 @@ impl CommandExecutor for std::process::Command { #[cfg(feature = "tokio")] /// Implement the [`CommandExecutor`] trait for [`Command`](tokio::process::Command) -#[allow(clippy::items_after_statements)] impl AsyncCommandExecutor for tokio::process::Command { /// Execute the command and return the stdout and stderr async fn execute(&mut self, timeout: Option) -> Result<(String, String)> { - #[tracing::instrument(level = "debug", skip(reader))] - async fn read_process( - mut reader: Option, - mut exit_anyway_broadcast_receiver: tokio::sync::broadcast::Receiver<()>, - ) -> Result { - let Some(reader) = reader.as_mut() else { - return Ok(String::new()); - }; - let mut vec = Vec::new(); - loop { - use tokio::io::AsyncReadExt as _; - tokio::select! { - n = reader.read_buf(&mut vec) => { - if n? == 0 { - return Ok(String::from_utf8_lossy(&vec).into_owned()); - } - }, - _ = exit_anyway_broadcast_receiver.recv() => { - return Ok(String::from_utf8_lossy(&vec).into_owned()); - }, - } - } - } - debug!("Executing command: {}", self.to_command_string()); + let output = match timeout { + Some(duration) => tokio::time::timeout(duration, self.output()).await?, + None => self.output().await, + }?; - let res_fut = async { - let mut child = self - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .spawn()?; - - let stdout = child.stdout.take(); - let stderr = child.stderr.take(); - - // on windows, pg_ctl start will appear to hang if you try to read out all of stdout - // and stderr. so, on windows do a horrible hack and forcibly end reading of stdout - // and stderr 50ms after the process exits. on not-windows, this early exit mechanism - // is set up but never sent to, resulting in the same behavior as `read_to_end`. - - let (exit_anyway_broadcast_sender, exit_anyway_broadcast_receiver_stdout) = - tokio::sync::broadcast::channel(1); - let exit_anyway_broadcast_receiver_stderr = exit_anyway_broadcast_sender.subscribe(); - let stdout = tokio::spawn(async { - read_process(stdout, exit_anyway_broadcast_receiver_stdout).await - }); - let stderr = tokio::spawn(async { - read_process(stderr, exit_anyway_broadcast_receiver_stderr).await - }); - let exit_status = child.wait().await; - #[cfg(target_os = "windows")] - { - tokio::time::sleep(Duration::from_millis(50)).await; - let _ = exit_anyway_broadcast_sender.send(()); - } - let (stdout, stderr) = tokio::join!(stdout, stderr); - drop(exit_anyway_broadcast_sender); - - let exit_status = exit_status?; - fn debug_render( - which: &'static str, - res: &std::result::Result, tokio::task::JoinError>, - ) -> String { - match res { - Ok(Ok(s)) => s.into(), - Ok(Err(io_err)) => format!(""), - Err(join_err) => format!(""), - } - } - debug!( - "Result: {}\nstdout: {}\nstderr: {}", - exit_status - .code() - .map_or("None".to_string(), |c| c.to_string()), - debug_render("stdout", &stdout), - debug_render("stderr", &stderr) - ); - - fn unwrap2_or_empty_string( - r: std::result::Result, E2>, - ) -> String { - r.map_or_else(|_| String::new(), |r| r.unwrap_or_else(|_| String::new())) - } + #[cfg(not(target_os = "windows"))] + let stdout = String::from_utf8_lossy(&output.stdout).into_owned(); + #[cfg(target_os = "windows")] + let stdout = String::new(); - let stdout = unwrap2_or_empty_string(stdout); - let stderr = unwrap2_or_empty_string(stderr); + #[cfg(not(target_os = "windows"))] + let stderr = String::from_utf8_lossy(&output.stderr).into_owned(); + #[cfg(target_os = "windows")] + let stderr = String::new(); - if exit_status.success() { - Ok((stdout, stderr)) - } else { - Err(Error::CommandError { stdout, stderr }) - } - }; + debug!( + "Result: {}\nstdout: {}\nstderr: {}", + output + .status + .code() + .map_or("None".to_string(), |c| c.to_string()), + stdout, + stderr + ); - match timeout { - Some(duration) => tokio::time::timeout(duration, res_fut).await?, - None => res_fut.await, + if output.status.success() { + Ok((stdout, stderr)) + } else { + Err(Error::CommandError { stdout, stderr }) } } } - #[cfg(test)] mod test { use super::*; From e89287ffbc5b8236a74f72bf78e065c293cfeadf Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 15:36:30 -0700 Subject: [PATCH 02/11] fix: correct hang when tokio is not used --- postgresql_commands/src/traits.rs | 70 +++++++++++++++++++------------ 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/postgresql_commands/src/traits.rs b/postgresql_commands/src/traits.rs index c1c9014..ec58adf 100644 --- a/postgresql_commands/src/traits.rs +++ b/postgresql_commands/src/traits.rs @@ -2,6 +2,7 @@ use crate::error::{Error, Result}; use std::ffi::{OsStr, OsString}; use std::fmt::Debug; use std::path::PathBuf; +use std::process::Child; use std::time::Duration; use tracing::debug; @@ -140,32 +141,46 @@ impl CommandExecutor for std::process::Command { /// Execute the command and return the stdout and stderr fn execute(&mut self) -> Result<(String, String)> { debug!("Executing command: {}", self.to_command_string()); - let output = self.output()?; - #[cfg(not(target_os = "windows"))] - let stdout = String::from_utf8_lossy(&output.stdout).into_owned(); - #[cfg(target_os = "windows")] - let stdout = String::new(); + { + let output = self.output()?; + let stdout = String::from_utf8_lossy(&output.stdout).into_owned(); + let stderr = String::from_utf8_lossy(&output.stderr).into_owned(); + + debug!( + "Result: {}\nstdout: {}\nstderr: {}", + output + .status + .code() + .map_or("None".to_string(), |c| c.to_string()), + stdout, + stderr + ); + + if output.status.success() { + Ok((stdout, stderr)) + } else { + Err(Error::CommandError { stdout, stderr }) + } + } - #[cfg(not(target_os = "windows"))] - let stderr = String::from_utf8_lossy(&output.stderr).into_owned(); + // TODO: Processes can hang on Windows when attempting to get stdout/stderr using code + // that works for Linux/MacOS; this implementation should be updated to retrieve the + // values of stdout/stderr without hanging #[cfg(target_os = "windows")] - let stderr = String::new(); - - debug!( - "Result: {}\nstdout: {}\nstderr: {}", - output - .status - .code() - .map_or("None".to_string(), |c| c.to_string()), - stdout, - stderr - ); - - if output.status.success() { - Ok((stdout, stderr)) - } else { - Err(Error::CommandError { stdout, stderr }) + { + let mut process = self + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .spawn()?; + let status = process.wait()?; + let stdout = String::new(); + let stderr = String::new(); + if status.success() { + Ok((stdout, stderr)) + } else { + Err(Error::CommandError { stdout, stderr }) + } } } } @@ -183,11 +198,14 @@ impl AsyncCommandExecutor for tokio::process::Command { #[cfg(not(target_os = "windows"))] let stdout = String::from_utf8_lossy(&output.stdout).into_owned(); - #[cfg(target_os = "windows")] - let stdout = String::new(); - #[cfg(not(target_os = "windows"))] let stderr = String::from_utf8_lossy(&output.stderr).into_owned(); + + // TODO: Processes can hang on Windows when attempting to get stdout/stderr using code + // that works for Linux/MacOS; this implementation should be updated to retrieve the + // values of stdout/stderr without hanging + #[cfg(target_os = "windows")] + let stdout = String::new(); #[cfg(target_os = "windows")] let stderr = String::new(); From 6b3f11b7a4246561f0cdbdac2e5b1ec4d301e011 Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 15:59:01 -0700 Subject: [PATCH 03/11] build: correct lint error --- postgresql_commands/src/traits.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/postgresql_commands/src/traits.rs b/postgresql_commands/src/traits.rs index ec58adf..8400bae 100644 --- a/postgresql_commands/src/traits.rs +++ b/postgresql_commands/src/traits.rs @@ -2,7 +2,6 @@ use crate::error::{Error, Result}; use std::ffi::{OsStr, OsString}; use std::fmt::Debug; use std::path::PathBuf; -use std::process::Child; use std::time::Duration; use tracing::debug; From 53e527f3d493037f8dfe7546c0ccca36b04cdf7b Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 18:08:54 -0700 Subject: [PATCH 04/11] fix: update command tests to work on Windows --- postgresql_commands/src/clusterdb.rs | 13 +++++++++-- postgresql_commands/src/createdb.rs | 13 +++++++++-- postgresql_commands/src/createuser.rs | 13 +++++++++-- postgresql_commands/src/dropdb.rs | 13 +++++++++-- postgresql_commands/src/dropuser.rs | 13 +++++++++-- postgresql_commands/src/ecpg.rs | 13 +++++++++-- postgresql_commands/src/initdb.rs | 13 +++++++++-- postgresql_commands/src/oid2name.rs | 13 +++++++++-- postgresql_commands/src/pg_amcheck.rs | 13 +++++++++-- postgresql_commands/src/pg_archivecleanup.rs | 13 +++++++++-- postgresql_commands/src/pg_basebackup.rs | 13 +++++++++-- postgresql_commands/src/pg_checksums.rs | 13 +++++++++-- postgresql_commands/src/pg_config.rs | 13 +++++++++-- postgresql_commands/src/pg_controldata.rs | 13 +++++++++-- postgresql_commands/src/pg_ctl.rs | 13 +++++++++-- postgresql_commands/src/pg_dump.rs | 14 ++++++++++-- postgresql_commands/src/pg_dumpall.rs | 13 +++++++++-- postgresql_commands/src/pg_isready.rs | 13 +++++++++-- postgresql_commands/src/pg_receivewal.rs | 13 +++++++++-- postgresql_commands/src/pg_recvlogical.rs | 13 +++++++++-- postgresql_commands/src/pg_resetwal.rs | 13 +++++++++-- postgresql_commands/src/pg_restore.rs | 13 +++++++++-- postgresql_commands/src/pg_rewind.rs | 13 +++++++++-- postgresql_commands/src/pg_test_fsync.rs | 13 +++++++++-- postgresql_commands/src/pg_test_timing.rs | 13 +++++++++-- postgresql_commands/src/pg_upgrade.rs | 13 +++++++++-- postgresql_commands/src/pg_verifybackup.rs | 13 +++++++++-- postgresql_commands/src/pg_waldump.rs | 13 +++++++++-- postgresql_commands/src/pgbench.rs | 13 +++++++++-- postgresql_commands/src/postgres.rs | 13 +++++++++-- postgresql_commands/src/psql.rs | 13 +++++++++-- postgresql_commands/src/reindexdb.rs | 13 +++++++++-- postgresql_commands/src/traits.rs | 19 ++++++++++++---- postgresql_commands/src/vacuumdb.rs | 13 +++++++++-- postgresql_commands/src/vacuumlo.rs | 13 +++++++++-- postgresql_embedded/src/lib.rs | 3 +++ postgresql_embedded/tests/start_config.rs | 23 ++++++++++---------- 37 files changed, 404 insertions(+), 84 deletions(-) diff --git a/postgresql_commands/src/clusterdb.rs b/postgresql_commands/src/clusterdb.rs index ca63922..a5bed37 100644 --- a/postgresql_commands/src/clusterdb.rs +++ b/postgresql_commands/src/clusterdb.rs @@ -274,8 +274,13 @@ mod tests { #[test] fn test_builder_from() { let command = ClusterDbBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./clusterdb" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\clusterdb" "#; + assert_eq!( - r#"PGPASSWORD="password" "./clusterdb" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -300,9 +305,13 @@ mod tests { .pg_password("password") .maintenance_db("postgres") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "clusterdb" "--all" "--dbname" "dbname" "--echo" "--quiet" "--table" "table" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres""#, + format!(r#"{command_prefix}"clusterdb" "--all" "--dbname" "dbname" "--echo" "--quiet" "--table" "table" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/createdb.rs b/postgresql_commands/src/createdb.rs index 156fe5c..22bb532 100644 --- a/postgresql_commands/src/createdb.rs +++ b/postgresql_commands/src/createdb.rs @@ -379,8 +379,13 @@ mod tests { #[test] fn test_builder_from() { let command = CreateDbBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./createdb" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\createdb" "#; + assert_eq!( - r#"PGPASSWORD="password" "./createdb" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -413,9 +418,13 @@ mod tests { .dbname("testdb") .description("Test Database") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "createdb" "--tablespace" "pg_default" "--echo" "--encoding" "UTF8" "--locale" "en_US.UTF-8" "--lc-collate" "en_US.UTF-8" "--lc-ctype" "en_US.UTF-8" "--icu-locale" "en_US" "--icu-rules" "standard" "--locale-provider" "icu" "--owner" "postgres" "--strategy" "wal_log" "--template" "template0" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "testdb" "Test Database""#, + format!(r#"{command_prefix}"createdb" "--tablespace" "pg_default" "--echo" "--encoding" "UTF8" "--locale" "en_US.UTF-8" "--lc-collate" "en_US.UTF-8" "--lc-ctype" "en_US.UTF-8" "--icu-locale" "en_US" "--icu-rules" "standard" "--locale-provider" "icu" "--owner" "postgres" "--strategy" "wal_log" "--template" "template0" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "testdb" "Test Database""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/createuser.rs b/postgresql_commands/src/createuser.rs index 223d318..b19c2e6 100644 --- a/postgresql_commands/src/createuser.rs +++ b/postgresql_commands/src/createuser.rs @@ -456,8 +456,13 @@ mod tests { #[test] fn test_builder_from() { let command = CreateUserBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./createuser" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\createuser" "#; + assert_eq!( - r#"PGPASSWORD="password" "./createuser" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -497,9 +502,13 @@ mod tests { .password() .pg_password("password") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "createuser" "--with-admin" "admin" "--connection-limit" "10" "--createdb" "--no-createdb" "--echo" "--member-of" "member" "--inherit" "--no-inherit" "--login" "--no-login" "--with-member" "member" "--pwprompt" "--createrole" "--no-createrole" "--superuser" "--no-superuser" "--valid-until" "2021-12-31" "--version" "--interactive" "--bypassrls" "--no-bypassrls" "--replication" "--no-replication" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""#, + format!(r#"{command_prefix}"createuser" "--with-admin" "admin" "--connection-limit" "10" "--createdb" "--no-createdb" "--echo" "--member-of" "member" "--inherit" "--no-inherit" "--login" "--no-login" "--with-member" "member" "--pwprompt" "--createrole" "--no-createrole" "--superuser" "--no-superuser" "--valid-until" "2021-12-31" "--version" "--interactive" "--bypassrls" "--no-bypassrls" "--replication" "--no-replication" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/dropdb.rs b/postgresql_commands/src/dropdb.rs index ff210a9..f7a92ad 100644 --- a/postgresql_commands/src/dropdb.rs +++ b/postgresql_commands/src/dropdb.rs @@ -259,8 +259,13 @@ mod tests { #[test] fn test_builder_from() { let command = DropDbBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./dropdb" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\dropdb" "#; + assert_eq!( - r#"PGPASSWORD="password" "./dropdb" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -284,9 +289,13 @@ mod tests { .maintenance_db("postgres") .dbname("dbname") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "dropdb" "--echo" "--force" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "dbname""#, + format!(r#"{command_prefix}"dropdb" "--echo" "--force" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "dbname""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/dropuser.rs b/postgresql_commands/src/dropuser.rs index 63ef0dc..df135ff 100644 --- a/postgresql_commands/src/dropuser.rs +++ b/postgresql_commands/src/dropuser.rs @@ -223,8 +223,13 @@ mod tests { #[test] fn test_builder_from() { let command = DropUserBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./dropuser" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\dropuser" "#; + assert_eq!( - r#"PGPASSWORD="password" "./dropuser" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -245,9 +250,13 @@ mod tests { .password() .pg_password("password") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "dropuser" "--echo" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#, + format!(r#"{command_prefix}"dropuser" "--echo" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/ecpg.rs b/postgresql_commands/src/ecpg.rs index 0647f29..53317de 100644 --- a/postgresql_commands/src/ecpg.rs +++ b/postgresql_commands/src/ecpg.rs @@ -230,7 +230,12 @@ mod tests { #[test] fn test_builder_from() { let command = EcpgBuilder::from(&TestSettings).build(); - assert_eq!(r#""./ecpg""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./ecpg""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\ecpg""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -250,9 +255,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "ecpg" "-c" "-C" "mode" "-D" "symbol" "-h" "-i" "-I" "directory" "-o" "outfile" "-r" "behavior" "--regression" "-t" "--version" "--help""#, + format!(r#"{command_prefix}"ecpg" "-c" "-C" "mode" "-D" "symbol" "-h" "-i" "-I" "directory" "-o" "outfile" "-r" "behavior" "--regression" "-t" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/initdb.rs b/postgresql_commands/src/initdb.rs index c56aeee..0cf1f38 100644 --- a/postgresql_commands/src/initdb.rs +++ b/postgresql_commands/src/initdb.rs @@ -526,8 +526,13 @@ mod tests { #[test] fn test_builder_from() { let command = InitDbBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./initdb" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\initdb" "#; + assert_eq!( - r#""./initdb" "--username" "postgres""#, + format!(r#"{command_prefix}"--username" "postgres""#), command.to_command_string() ); } @@ -572,9 +577,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "initdb" "--auth" "md5" "--auth-host" "md5" "--auth-local" "md5" "--pgdata" "pgdata" "--encoding" "UTF8" "--allow-group-access" "--icu-locale" "en_US" "--icu-rules" "phonebook" "--data-checksums" "--locale" "en_US" "--lc-collate" "en_US" "--lc-ctype" "en_US" "--lc-messages" "en_US" "--lc-monetary" "en_US" "--lc-numeric" "en_US" "--lc-time" "en_US" "--no-locale" "--locale-provider" "icu" "--pwfile" ".pwfile" "--text-search-config" "english" "--username" "postgres" "--pwprompt" "--waldir" "waldir" "--wal-segsize" "1" "--set" "timezone=UTC" "--debug" "--discard-caches" "--directory" "directory" "--no-clean" "--no-sync" "--no-instructions" "--show" "--sync-only" "--version" "--help""#, + format!(r#"{command_prefix}"initdb" "--auth" "md5" "--auth-host" "md5" "--auth-local" "md5" "--pgdata" "pgdata" "--encoding" "UTF8" "--allow-group-access" "--icu-locale" "en_US" "--icu-rules" "phonebook" "--data-checksums" "--locale" "en_US" "--lc-collate" "en_US" "--lc-ctype" "en_US" "--lc-messages" "en_US" "--lc-monetary" "en_US" "--lc-numeric" "en_US" "--lc-time" "en_US" "--no-locale" "--locale-provider" "icu" "--pwfile" ".pwfile" "--text-search-config" "english" "--username" "postgres" "--pwprompt" "--waldir" "waldir" "--wal-segsize" "1" "--set" "timezone=UTC" "--debug" "--discard-caches" "--directory" "directory" "--no-clean" "--no-sync" "--no-instructions" "--show" "--sync-only" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/oid2name.rs b/postgresql_commands/src/oid2name.rs index 4711136..5fb03bd 100644 --- a/postgresql_commands/src/oid2name.rs +++ b/postgresql_commands/src/oid2name.rs @@ -260,8 +260,13 @@ mod tests { #[test] fn test_builder_from() { let command = Oid2NameBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./oid2name" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\oid2name" "#; + assert_eq!( - r#""./oid2name" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -285,9 +290,13 @@ mod tests { .port(5432) .username("username") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "oid2name" "--filenode" "filenode" "--indexes" "--oid" "oid" "--quiet" "--tablespaces" "--system-objects" "--table" "table" "--version" "--extended" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username""#, + format!(r#"{command_prefix}"oid2name" "--filenode" "filenode" "--indexes" "--oid" "oid" "--quiet" "--tablespaces" "--system-objects" "--table" "table" "--version" "--extended" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_amcheck.rs b/postgresql_commands/src/pg_amcheck.rs index 2a3c98a..065fae8 100644 --- a/postgresql_commands/src/pg_amcheck.rs +++ b/postgresql_commands/src/pg_amcheck.rs @@ -539,8 +539,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgAmCheckBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_amcheck" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_amcheck" "#; + assert_eq!( - r#"PGPASSWORD="password" "./pg_amcheck" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -586,9 +591,13 @@ mod tests { .install_missing() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "pg_amcheck" "--all" "--database" "database" "--exclude-database" "exclude_database" "--index" "index" "--exclude-index" "exclude_index" "--relation" "relation" "--exclude-relation" "exclude_relation" "--schema" "schema" "--exclude-schema" "exclude_schema" "--table" "table" "--exclude-table" "exclude_table" "--no-dependent-indexes" "--no-dependent-toast" "--no-strict-names" "--exclude-toast-pointers" "--on-error-stop" "--skip" "skip" "--startblock" "start_block" "--endblock" "end_block" "--heapallindexed" "--parent-check" "--rootdescend" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db" "--echo" "--jobs" "jobs" "--progress" "--verbose" "--version" "--install-missing" "--help""#, + format!(r#"{command_prefix}"pg_amcheck" "--all" "--database" "database" "--exclude-database" "exclude_database" "--index" "index" "--exclude-index" "exclude_index" "--relation" "relation" "--exclude-relation" "exclude_relation" "--schema" "schema" "--exclude-schema" "exclude_schema" "--table" "table" "--exclude-table" "exclude_table" "--no-dependent-indexes" "--no-dependent-toast" "--no-strict-names" "--exclude-toast-pointers" "--on-error-stop" "--skip" "skip" "--startblock" "start_block" "--endblock" "end_block" "--heapallindexed" "--parent-check" "--rootdescend" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db" "--echo" "--jobs" "jobs" "--progress" "--verbose" "--version" "--install-missing" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_archivecleanup.rs b/postgresql_commands/src/pg_archivecleanup.rs index b7c8850..7b76a69 100644 --- a/postgresql_commands/src/pg_archivecleanup.rs +++ b/postgresql_commands/src/pg_archivecleanup.rs @@ -166,7 +166,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgArchiveCleanupBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_archivecleanup""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_archivecleanup""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_archivecleanup""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -181,9 +186,13 @@ mod tests { .archive_location("archive_location") .oldest_kept_wal_file("000000010000000000000001") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_archivecleanup" "-d" "-n" "--version" "-x" "partial" "--help" "archive_location" "000000010000000000000001""#, + format!(r#"{command_prefix}"pg_archivecleanup" "-d" "-n" "--version" "-x" "partial" "--help" "archive_location" "000000010000000000000001""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_basebackup.rs b/postgresql_commands/src/pg_basebackup.rs index 0b327fc..a998e28 100644 --- a/postgresql_commands/src/pg_basebackup.rs +++ b/postgresql_commands/src/pg_basebackup.rs @@ -514,8 +514,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgBaseBackupBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_basebackup" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_basebackup" "#; + assert_eq!( - r#"PGPASSWORD="password" "./pg_basebackup" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -559,9 +564,13 @@ mod tests { .password() .pg_password("password") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "pg_basebackup" "--pgdata" "pgdata" "--format" "plain" "--max-rate" "100M" "--write-recovery-conf" "--target" "localhost" "--tablespace-mapping" "tablespace_mapping" "--waldir" "waldir" "--wal-method" "stream" "--gzip" "--compress" "client" "--checkpoint" "fast" "--create-slot" "--label" "my_backup" "--no-clean" "--no-sync" "--progress" "--slot" "my_slot" "--verbose" "--version" "--manifest-checksums" "sha256" "--manifest-force-encode" "--no-estimate-size" "--no-manifest" "--no-slot" "--no-verify-checksums" "--help" "--dbname" "postgres" "--host" "localhost" "--port" "5432" "--status-interval" "10" "--username" "postgres" "--no-password" "--password""#, + format!(r#"{command_prefix}"pg_basebackup" "--pgdata" "pgdata" "--format" "plain" "--max-rate" "100M" "--write-recovery-conf" "--target" "localhost" "--tablespace-mapping" "tablespace_mapping" "--waldir" "waldir" "--wal-method" "stream" "--gzip" "--compress" "client" "--checkpoint" "fast" "--create-slot" "--label" "my_backup" "--no-clean" "--no-sync" "--progress" "--slot" "my_slot" "--verbose" "--version" "--manifest-checksums" "sha256" "--manifest-force-encode" "--no-estimate-size" "--no-manifest" "--no-slot" "--no-verify-checksums" "--help" "--dbname" "postgres" "--host" "localhost" "--port" "5432" "--status-interval" "10" "--username" "postgres" "--no-password" "--password""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_checksums.rs b/postgresql_commands/src/pg_checksums.rs index f0c2389..ef311a9 100644 --- a/postgresql_commands/src/pg_checksums.rs +++ b/postgresql_commands/src/pg_checksums.rs @@ -203,7 +203,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgChecksumsBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_checksums""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_checksums""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_checksums""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -221,9 +226,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_checksums" "--pgdata" "pgdata" "--check" "--disable" "--enable" "--filenode" "12345" "--no-sync" "--progress" "--verbose" "--version" "--help""#, + format!(r#"{command_prefix}"pg_checksums" "--pgdata" "pgdata" "--check" "--disable" "--enable" "--filenode" "12345" "--no-sync" "--progress" "--verbose" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_config.rs b/postgresql_commands/src/pg_config.rs index 6e2dab6..5e38e47 100644 --- a/postgresql_commands/src/pg_config.rs +++ b/postgresql_commands/src/pg_config.rs @@ -382,7 +382,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgConfigBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_config""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_config""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_config""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -414,9 +419,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_config" "--bindir" "bindir" "--docdir" "docdir" "--htmldir" "htmldir" "--includedir" "includedir" "--pkgincludedir" "pkgincludedir" "--includedir-server" "includedir_server" "--libdir" "libdir" "--pkglibdir" "pkglibdir" "--localedir" "localedir" "--mandir" "mandir" "--sharedir" "sharedir" "--sysconfdir" "sysconfdir" "--pgxs" "pgxs" "--configure" "--cc" "--cppflags" "--cflags" "--cflags_sl" "--ldflags" "--ldflags_ex" "--ldflags_sl" "--libs" "--version" "--help""#, + format!(r#"{command_prefix}"pg_config" "--bindir" "bindir" "--docdir" "docdir" "--htmldir" "htmldir" "--includedir" "includedir" "--pkgincludedir" "pkgincludedir" "--includedir-server" "includedir_server" "--libdir" "libdir" "--pkglibdir" "pkglibdir" "--localedir" "localedir" "--mandir" "mandir" "--sharedir" "sharedir" "--sysconfdir" "sysconfdir" "--pgxs" "pgxs" "--configure" "--cc" "--cppflags" "--cflags" "--cflags_sl" "--ldflags" "--ldflags_ex" "--ldflags_sl" "--libs" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_controldata.rs b/postgresql_commands/src/pg_controldata.rs index 57903f0..a1f8942 100644 --- a/postgresql_commands/src/pg_controldata.rs +++ b/postgresql_commands/src/pg_controldata.rs @@ -117,7 +117,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgControlDataBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_controldata""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_controldata""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_controldata""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -128,9 +133,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_controldata" "--pgdata" "pgdata" "--version" "--help""#, + format!(r#"{command_prefix}"pg_controldata" "--pgdata" "pgdata" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_ctl.rs b/postgresql_commands/src/pg_ctl.rs index d2d8641..6646562 100644 --- a/postgresql_commands/src/pg_ctl.rs +++ b/postgresql_commands/src/pg_ctl.rs @@ -334,7 +334,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgCtlBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_ctl""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"./pg_ctl""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_ctl""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -357,9 +362,13 @@ mod tests { .signal("HUP") .pid("12345") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_ctl" "start" "--pgdata" "pgdata" "--silent" "--timeout" "60" "--version" "--wait" "--no-wait" "--help" "--core-files" "--log" "log" "-o" "-c log_connections=on" "-p" "path_to_postgres" "--mode" "smart" "HUP" "12345""#, + format!(r#"{command_prefix}"pg_ctl" "start" "--pgdata" "pgdata" "--silent" "--timeout" "60" "--version" "--wait" "--no-wait" "--help" "--core-files" "--log" "log" "-o" "-c log_connections=on" "-p" "path_to_postgres" "--mode" "smart" "HUP" "12345""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_dump.rs b/postgresql_commands/src/pg_dump.rs index 637409b..18003a2 100644 --- a/postgresql_commands/src/pg_dump.rs +++ b/postgresql_commands/src/pg_dump.rs @@ -849,8 +849,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgDumpBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_dump" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_dump" "#; + assert_eq!( - r#"PGPASSWORD="password" "./pg_dump" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -921,8 +926,13 @@ mod tests { .pg_password("password") .role("role") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); + assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "pg_dump" "--data-only" "--large-objects" "--no-large-objects" "--clean" "--create" "--extension" "extension" "--encoding" "UTF8" "--file" "file" "--format" "format" "--jobs" "jobs" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--no-reconnect" "--schema-only" "--superuser" "superuser" "--table" "table" "--exclude-table" "exclude_table" "--verbose" "--version" "--no-privileges" "--compression" "compression" "--binary-upgrade" "--column-inserts" "--attribute-inserts" "--disable-dollar-quoting" "--disable-triggers" "--enable-row-security" "--exclude-table-data-and-children" "exclude_table_data_and_children" "--extra-float-digits" "extra_float_digits" "--if-exists" "--include-foreign-data" "include_foreign_data" "--inserts" "--load-via-partition-root" "--lock-wait-timeout" "10" "--no-comments" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "100" "--section" "section" "--serializable-deferrable" "--snapshot" "snapshot" "--strict-names" "--table-and-children" "table_and_children" "--use-set-session-authorization" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "role""#, + format!(r#"{command_prefix}"pg_dump" "--data-only" "--large-objects" "--no-large-objects" "--clean" "--create" "--extension" "extension" "--encoding" "UTF8" "--file" "file" "--format" "format" "--jobs" "jobs" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--no-reconnect" "--schema-only" "--superuser" "superuser" "--table" "table" "--exclude-table" "exclude_table" "--verbose" "--version" "--no-privileges" "--compression" "compression" "--binary-upgrade" "--column-inserts" "--attribute-inserts" "--disable-dollar-quoting" "--disable-triggers" "--enable-row-security" "--exclude-table-data-and-children" "exclude_table_data_and_children" "--extra-float-digits" "extra_float_digits" "--if-exists" "--include-foreign-data" "include_foreign_data" "--inserts" "--load-via-partition-root" "--lock-wait-timeout" "10" "--no-comments" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "100" "--section" "section" "--serializable-deferrable" "--snapshot" "snapshot" "--strict-names" "--table-and-children" "table_and_children" "--use-set-session-authorization" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "role""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_dumpall.rs b/postgresql_commands/src/pg_dumpall.rs index 9e6f6a7..7a59f26 100644 --- a/postgresql_commands/src/pg_dumpall.rs +++ b/postgresql_commands/src/pg_dumpall.rs @@ -666,8 +666,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgDumpAllBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_dumpall" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_dumpall" "#; + assert_eq!( - r#"PGPASSWORD="password" "./pg_dumpall" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -724,9 +729,13 @@ mod tests { .pg_password("password") .role("postgres") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "pg_dumpall" "--file" "dump.sql" "--verbose" "--version" "--lock-wait-timeout" "10" "--help" "--data-only" "--clean" "--encoding" "UTF8" "--globals-only" "--no-owner" "--roles-only" "--schema-only" "--superuser" "postgres" "--tablespaces-only" "--no-privileges" "--binary-upgrade" "--column-inserts" "--disable-dollar-quoting" "--disable-triggers" "--exclude-database" "exclude" "--extra-float-digits" "2" "--if-exists" "--inserts" "--load-via-partition-root" "--no-comments" "--no-publications" "--no-role-passwords" "--no-security-labels" "--no-subscriptions" "--no-sync" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "1000" "--use-set-session-authorization" "--dbname" "postgres" "--host" "localhost" "--database" "postgres" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "postgres""#, + format!(r#"{command_prefix}"pg_dumpall" "--file" "dump.sql" "--verbose" "--version" "--lock-wait-timeout" "10" "--help" "--data-only" "--clean" "--encoding" "UTF8" "--globals-only" "--no-owner" "--roles-only" "--schema-only" "--superuser" "postgres" "--tablespaces-only" "--no-privileges" "--binary-upgrade" "--column-inserts" "--disable-dollar-quoting" "--disable-triggers" "--exclude-database" "exclude" "--extra-float-digits" "2" "--if-exists" "--inserts" "--load-via-partition-root" "--no-comments" "--no-publications" "--no-role-passwords" "--no-security-labels" "--no-subscriptions" "--no-sync" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "1000" "--use-set-session-authorization" "--dbname" "postgres" "--host" "localhost" "--database" "postgres" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "postgres""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_isready.rs b/postgresql_commands/src/pg_isready.rs index 1fcde53..b183d27 100644 --- a/postgresql_commands/src/pg_isready.rs +++ b/postgresql_commands/src/pg_isready.rs @@ -186,8 +186,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgIsReadyBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_isready" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_isready" "#; + assert_eq!( - r#""./pg_isready" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -205,9 +210,13 @@ mod tests { .timeout(3) .username("postgres") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_isready" "--dbname" "postgres" "--quiet" "--version" "--help" "--host" "localhost" "--port" "5432" "--timeout" "3" "--username" "postgres""#, + format!(r#"{command_prefix}"pg_isready" "--dbname" "postgres" "--quiet" "--version" "--help" "--host" "localhost" "--port" "5432" "--timeout" "3" "--username" "postgres""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_receivewal.rs b/postgresql_commands/src/pg_receivewal.rs index 1d95473..c3436e4 100644 --- a/postgresql_commands/src/pg_receivewal.rs +++ b/postgresql_commands/src/pg_receivewal.rs @@ -349,8 +349,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgReceiveWalBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_receivewal" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_receivewal" "#; + assert_eq!( - r#"PGPASSWORD="password" "./pg_receivewal" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -381,9 +386,13 @@ mod tests { .create_slot() .drop_slot() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "pg_receivewal" "--directory" "directory" "--endpos" "endpos" "--if-not-exists" "--no-loop" "--no-sync" "--status-interval" "status_interval" "--slot" "slot" "--synchronous" "--verbose" "--version" "--compress" "compress" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--create-slot" "--drop-slot""#, + format!(r#"{command_prefix}"pg_receivewal" "--directory" "directory" "--endpos" "endpos" "--if-not-exists" "--no-loop" "--no-sync" "--status-interval" "status_interval" "--slot" "slot" "--synchronous" "--verbose" "--version" "--compress" "compress" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--create-slot" "--drop-slot""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_recvlogical.rs b/postgresql_commands/src/pg_recvlogical.rs index 0f57ac0..44a9590 100644 --- a/postgresql_commands/src/pg_recvlogical.rs +++ b/postgresql_commands/src/pg_recvlogical.rs @@ -388,8 +388,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgRecvLogicalBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_recvlogical" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_recvlogical" "#; + assert_eq!( - r#"PGPASSWORD="password" "./pg_recvlogical" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -423,9 +428,13 @@ mod tests { .password() .pg_password("password") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "pg_recvlogical" "--create-slot" "--drop-slot" "--start" "--endpos" "endpos" "--file" "file" "--fsync-interval" "fsync_interval" "--if-not-exists" "--startpos" "startpos" "--no-loop" "--option" "option" "--plugin" "plugin" "--status-interval" "status_interval" "--slot" "slot" "--two-phase" "--verbose" "--version" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""#, + format!(r#"{command_prefix}"pg_recvlogical" "--create-slot" "--drop-slot" "--start" "--endpos" "endpos" "--file" "file" "--fsync-interval" "fsync_interval" "--if-not-exists" "--startpos" "startpos" "--no-loop" "--option" "option" "--plugin" "plugin" "--status-interval" "status_interval" "--slot" "slot" "--two-phase" "--verbose" "--version" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_resetwal.rs b/postgresql_commands/src/pg_resetwal.rs index fffb729..1b768cb 100644 --- a/postgresql_commands/src/pg_resetwal.rs +++ b/postgresql_commands/src/pg_resetwal.rs @@ -259,7 +259,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgResetWalBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_resetwal""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_resetwal""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_resetwal""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -281,9 +286,13 @@ mod tests { .wal_segsize("wal_segsize") .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_resetwal" "--commit-timestamp-ids" "1,2" "--pgdata" "pgdata" "--epoch" "epoch" "--force" "--next-wal-file" "next_wal_file" "--multixact-ids" "3,4" "--dry-run" "--next-oid" "next_oid" "--multixact-offset" "multixact_offset" "--oldest-transaction-id" "oldest_transaction_id" "--version" "--next-transaction-id" "next_transaction_id" "--wal-segsize" "wal_segsize" "--help""#, + format!(r#"{command_prefix}"pg_resetwal" "--commit-timestamp-ids" "1,2" "--pgdata" "pgdata" "--epoch" "epoch" "--force" "--next-wal-file" "next_wal_file" "--multixact-ids" "3,4" "--dry-run" "--next-oid" "next_oid" "--multixact-offset" "multixact_offset" "--oldest-transaction-id" "oldest_transaction_id" "--version" "--next-transaction-id" "next_transaction_id" "--wal-segsize" "wal_segsize" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_restore.rs b/postgresql_commands/src/pg_restore.rs index 36d26ce..b4e0719 100644 --- a/postgresql_commands/src/pg_restore.rs +++ b/postgresql_commands/src/pg_restore.rs @@ -634,8 +634,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgRestoreBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./pg_restore" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_restore" "#; + assert_eq!( - r#"PGPASSWORD="password" "./pg_restore" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -689,9 +694,13 @@ mod tests { .pg_password("password") .role("role") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "pg_restore" "--dbname" "dbname" "--file" "file" "--format" "format" "--list" "--verbose" "--version" "--help" "--data-only" "--clean" "--create" "--exit-on-error" "--index" "index" "--jobs" "jobs" "--use-list" "use_list" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--function" "function" "--schema-only" "--superuser" "superuser" "--table" "table" "--trigger" "trigger" "--no-privileges" "--single-transaction" "--disable-triggers" "--enable-row-security" "--if-exists" "--no-comments" "--no-data-for-failed-tables" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--section" "section" "--strict-names" "--use-set-session-authorization" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--role" "role""#, + format!(r#"{command_prefix}"pg_restore" "--dbname" "dbname" "--file" "file" "--format" "format" "--list" "--verbose" "--version" "--help" "--data-only" "--clean" "--create" "--exit-on-error" "--index" "index" "--jobs" "jobs" "--use-list" "use_list" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--function" "function" "--schema-only" "--superuser" "superuser" "--table" "table" "--trigger" "trigger" "--no-privileges" "--single-transaction" "--disable-triggers" "--enable-row-security" "--if-exists" "--no-comments" "--no-data-for-failed-tables" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--section" "section" "--strict-names" "--use-set-session-authorization" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--role" "role""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_rewind.rs b/postgresql_commands/src/pg_rewind.rs index d076992..4186f2c 100644 --- a/postgresql_commands/src/pg_rewind.rs +++ b/postgresql_commands/src/pg_rewind.rs @@ -241,7 +241,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgRewindBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_rewind""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_rewind""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_rewind""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -262,9 +267,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_rewind" "--restore-target-wal" "--target-pgdata" "target_pgdata" "--source-pgdata" "source_pgdata" "--source-server" "source_server" "--dry-run" "--no-sync" "--progress" "--write-recovery-conf" "--config-file" "config_file" "--debug" "--no-ensure-shutdown" "--version" "--help""#, + format!(r#"{command_prefix}"pg_rewind" "--restore-target-wal" "--target-pgdata" "target_pgdata" "--source-pgdata" "source_pgdata" "--source-server" "source_server" "--dry-run" "--no-sync" "--progress" "--write-recovery-conf" "--config-file" "config_file" "--debug" "--no-ensure-shutdown" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_test_fsync.rs b/postgresql_commands/src/pg_test_fsync.rs index bcfd9d5..5084b9b 100644 --- a/postgresql_commands/src/pg_test_fsync.rs +++ b/postgresql_commands/src/pg_test_fsync.rs @@ -107,7 +107,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgTestFsyncBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_test_fsync""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_test_fsync""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_test_fsync""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -117,9 +122,13 @@ mod tests { .filename("filename") .secs_per_test(10) .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_test_fsync" "-f" "filename" "-s" "10""#, + format!(r#"{command_prefix}"pg_test_fsync" "-f" "filename" "-s" "10""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_test_timing.rs b/postgresql_commands/src/pg_test_timing.rs index a08805e..8d85f15 100644 --- a/postgresql_commands/src/pg_test_timing.rs +++ b/postgresql_commands/src/pg_test_timing.rs @@ -94,7 +94,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgTestTimingBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_test_timing""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_test_timing""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_test_timing""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -103,9 +108,13 @@ mod tests { .env("PGDATABASE", "database") .duration("10") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_test_timing" "-d" "10""#, + format!(r#"{command_prefix}"pg_test_timing" "-d" "10""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_upgrade.rs b/postgresql_commands/src/pg_upgrade.rs index cbbbee6..70e51ef 100644 --- a/postgresql_commands/src/pg_upgrade.rs +++ b/postgresql_commands/src/pg_upgrade.rs @@ -332,7 +332,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgUpgradeBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_upgrade""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_upgrade""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_upgrade""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -360,9 +365,13 @@ mod tests { .copy() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_upgrade" "--old-bindir" "old" "--new-bindir" "new" "--check" "--old-datadir" "old_data" "--new-datadir" "new_data" "--jobs" "10" "--link" "--no-sync" "--old-options" "old" "--new-options" "new" "--old-port" "5432" "--new-port" "5433" "--retain" "--socketdir" "socket" "--username" "user" "--verbose" "--version" "--clone" "--copy" "--help""#, + format!(r#"{command_prefix}"pg_upgrade" "--old-bindir" "old" "--new-bindir" "new" "--check" "--old-datadir" "old_data" "--new-datadir" "new_data" "--jobs" "10" "--link" "--no-sync" "--old-options" "old" "--new-options" "new" "--old-port" "5432" "--new-port" "5433" "--retain" "--socketdir" "socket" "--username" "user" "--verbose" "--version" "--clone" "--copy" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_verifybackup.rs b/postgresql_commands/src/pg_verifybackup.rs index e988a9c..da0de1e 100644 --- a/postgresql_commands/src/pg_verifybackup.rs +++ b/postgresql_commands/src/pg_verifybackup.rs @@ -204,7 +204,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgVerifyBackupBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_verifybackup""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_verifybackup""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_verifybackup""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -222,9 +227,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_verifybackup" "--exit-on-error" "--ignore" "ignore" "--manifest-path" "manifest-path" "--no-parse-wal" "--progress" "--quiet" "--skip-checksums" "--wal-directory" "wal_directory" "--version" "--help""#, + format!(r#"{command_prefix}"pg_verifybackup" "--exit-on-error" "--ignore" "ignore" "--manifest-path" "manifest-path" "--no-parse-wal" "--progress" "--quiet" "--skip-checksums" "--wal-directory" "wal_directory" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_waldump.rs b/postgresql_commands/src/pg_waldump.rs index 1e7f98f..eff020d 100644 --- a/postgresql_commands/src/pg_waldump.rs +++ b/postgresql_commands/src/pg_waldump.rs @@ -309,7 +309,12 @@ mod tests { #[test] fn test_builder_from() { let command = PgWalDumpBuilder::from(&TestSettings).build(); - assert_eq!(r#""./pg_waldump""#, command.to_command_string()); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./pg_waldump""#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pg_waldump""#; + + assert_eq!(format!("{command_prefix}"), command.to_command_string()); } #[test] @@ -335,9 +340,13 @@ mod tests { .save_fullpage("save_fullpage") .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pg_waldump" "--bkp-details" "--block" "block" "--end" "end" "--follow" "--fork" "fork" "--limit" "limit" "--path" "path" "--quiet" "--rmgr" "rmgr" "--relation" "relation" "--start" "start" "--timeline" "timeline" "--version" "--fullpage" "--xid" "xid" "--stats" "stats" "--save-fullpage" "save_fullpage" "--help""#, + format!(r#"{command_prefix}"pg_waldump" "--bkp-details" "--block" "block" "--end" "end" "--follow" "--fork" "fork" "--limit" "limit" "--path" "path" "--quiet" "--rmgr" "rmgr" "--relation" "relation" "--start" "start" "--timeline" "timeline" "--version" "--fullpage" "--xid" "xid" "--stats" "stats" "--save-fullpage" "save_fullpage" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/pgbench.rs b/postgresql_commands/src/pgbench.rs index c6add0b..b06be9b 100644 --- a/postgresql_commands/src/pgbench.rs +++ b/postgresql_commands/src/pgbench.rs @@ -666,8 +666,13 @@ mod tests { #[test] fn test_builder_from() { let command = PgBenchBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"./pgbench" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\pgbench" "#; + assert_eq!( - r#""./pgbench" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -723,9 +728,13 @@ mod tests { .version() .help() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "pgbench" "--initialize" "--init-steps" "steps" "--fillfactor" "10" "--no-vacuum" "--quiet" "--scale" "10" "--foreign-keys" "--index-tablespace" "tablespace" "--partition-method" "method" "--partitions" "10" "--tablespace" "tablespace" "--unlogged-tables" "--builtin" "name" "--file" "filename" "--skip-some-updates" "--select-only" "--client" "10" "--connect" "--define" "var" "--jobs" "10" "--log" "--latency-limit" "10" "--protocol" "protocol" "--no-vacuum" "--progress" "10" "--report-per-command" "--rate" "10" "--scale" "10" "--transactions" "10" "--time" "10" "--vacuum-all" "--aggregate-interval" "10" "--failures-detailed" "--log-prefix" "prefix" "--max-tries" "10" "--progress-timestamp" "--random-seed" "seed" "--sampling-rate" "10" "--show-script" "name" "--verbose-errors" "--debug" "--host" "localhost" "--port" "5432" "--username" "username" "--version" "--help""#, + format!(r#"{command_prefix}"pgbench" "--initialize" "--init-steps" "steps" "--fillfactor" "10" "--no-vacuum" "--quiet" "--scale" "10" "--foreign-keys" "--index-tablespace" "tablespace" "--partition-method" "method" "--partitions" "10" "--tablespace" "tablespace" "--unlogged-tables" "--builtin" "name" "--file" "filename" "--skip-some-updates" "--select-only" "--client" "10" "--connect" "--define" "var" "--jobs" "10" "--log" "--latency-limit" "10" "--protocol" "protocol" "--no-vacuum" "--progress" "10" "--report-per-command" "--rate" "10" "--scale" "10" "--transactions" "10" "--time" "10" "--vacuum-all" "--aggregate-interval" "10" "--failures-detailed" "--log-prefix" "prefix" "--max-tries" "10" "--progress-timestamp" "--random-seed" "seed" "--sampling-rate" "10" "--show-script" "name" "--verbose-errors" "--debug" "--host" "localhost" "--port" "5432" "--username" "username" "--version" "--help""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/postgres.rs b/postgresql_commands/src/postgres.rs index 62e6aea..dd183ab 100644 --- a/postgresql_commands/src/postgres.rs +++ b/postgresql_commands/src/postgres.rs @@ -471,8 +471,13 @@ mod tests { #[test] fn test_builder_from() { let command = PostgresBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#""./postgres" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\postgres" "#; + assert_eq!( - r#""./postgres" "-h" "localhost" "-p" "5432""#, + format!(r#"{command_prefix}"-h" "localhost" "-p" "5432""#), command.to_command_string() ); } @@ -513,9 +518,13 @@ mod tests { .bootstrapping_mode() .check_mode() .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" "postgres" "-B" "100" "-c" "name=value" "-C" "name" "-d" "3" "-D" "data_dir" "-e" "-F" "-h" "localhost" "-i" "-k" "socket_location" "-N" "100" "-p" "5432" "-s" "-S" "100" "--version" "--describe-config" "--help" "-f" "type" "-O" "-P" "-t" "timings" "-T" "-W" "10" "--single" "dbname" "-d" "3" "-E" "-j" "-r" "output_file" "--boot" "--check""#, + format!(r#"{command_prefix}"postgres" "-B" "100" "-c" "name=value" "-C" "name" "-d" "3" "-D" "data_dir" "-e" "-F" "-h" "localhost" "-i" "-k" "socket_location" "-N" "100" "-p" "5432" "-s" "-S" "100" "--version" "--describe-config" "--help" "-f" "type" "-O" "-P" "-t" "timings" "-T" "-W" "10" "--single" "dbname" "-d" "3" "-E" "-j" "-r" "output_file" "--boot" "--check""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/psql.rs b/postgresql_commands/src/psql.rs index f3ae4b0..3fbec02 100644 --- a/postgresql_commands/src/psql.rs +++ b/postgresql_commands/src/psql.rs @@ -537,8 +537,13 @@ mod tests { #[test] fn test_builder_from() { let command = PsqlBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./psql" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\psql" "#; + assert_eq!( - r#"PGPASSWORD="password" "./psql" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -584,9 +589,13 @@ mod tests { .password() .pg_password("password") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "psql" "--command" "SELECT * FROM test" "--dbname" "dbname" "--file" "test.sql" "--list" "--variable" "ON_ERROR_STOP=1" "--version" "--no-psqlrc" "--single-transaction" "--help" "options" "--echo-all" "--echo-errors" "--echo-queries" "--echo-hidden" "--log-file" "psql.log" "--no-readline" "--output" "output.txt" "--quiet" "--single-step" "--single-line" "--no-align" "--csv" "--field-separator" "|" "--html" "--pset" "border=1" "--record-separator" "\n" "--tuples-only" "--table-attr" "width=100" "--expanded" "--field-separator-zero" "--record-separator-zero" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#, + format!(r#"{command_prefix}"psql" "--command" "SELECT * FROM test" "--dbname" "dbname" "--file" "test.sql" "--list" "--variable" "ON_ERROR_STOP=1" "--version" "--no-psqlrc" "--single-transaction" "--help" "options" "--echo-all" "--echo-errors" "--echo-queries" "--echo-hidden" "--log-file" "psql.log" "--no-readline" "--output" "output.txt" "--quiet" "--single-step" "--single-line" "--no-align" "--csv" "--field-separator" "|" "--html" "--pset" "border=1" "--record-separator" "\n" "--tuples-only" "--table-attr" "width=100" "--expanded" "--field-separator-zero" "--record-separator-zero" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/reindexdb.rs b/postgresql_commands/src/reindexdb.rs index 8799a86..6e490dc 100644 --- a/postgresql_commands/src/reindexdb.rs +++ b/postgresql_commands/src/reindexdb.rs @@ -349,8 +349,13 @@ mod tests { #[test] fn test_builder_from() { let command = ReindexDbBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./reindexdb" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\reindexdb" "#; + assert_eq!( - r#"PGPASSWORD="password" "./reindexdb" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -381,9 +386,13 @@ mod tests { .pg_password("password") .maintenance_db("maintenance-db") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "reindexdb" "--all" "--concurrently" "--dbname" "dbname" "--echo" "--index" "index" "--jobs" "1" "--quiet" "--system" "--schema" "schema" "--table" "table" "--tablespace" "tablespace" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance-db""#, + format!(r#"{command_prefix}"reindexdb" "--all" "--concurrently" "--dbname" "dbname" "--echo" "--index" "index" "--jobs" "1" "--quiet" "--system" "--schema" "schema" "--table" "table" "--tablespace" "tablespace" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance-db""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/traits.rs b/postgresql_commands/src/traits.rs index 8400bae..75a5298 100644 --- a/postgresql_commands/src/traits.rs +++ b/postgresql_commands/src/traits.rs @@ -260,8 +260,12 @@ mod test { let builder = DefaultCommandBuilder::default(); let command = builder.env("ENV", "foo").build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"ENV="foo" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); - assert_eq!(r#"ENV="foo" "test""#, command.to_command_string()); + assert_eq!(format!(r#"{command_prefix}"test""#), command.to_command_string()); } #[derive(Debug)] @@ -303,10 +307,14 @@ mod test { envs: vec![], }; let command = builder.env("PASSWORD", "foo").build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PASSWORD="foo" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( format!( - r#"PASSWORD="foo" "{}" "--help""#, + r#"{command_prefix}"{}" "--help""#, PathBuf::from("test").to_string_lossy() ), command.to_command_string() @@ -357,10 +365,13 @@ mod test { #[cfg(target_os = "windows")] let mut command = std::process::Command::new("cmd"); #[cfg(target_os = "windows")] - command.args(&["/C", "echo foo"]); + command.args(["/C", "echo foo"]); let (stdout, stderr) = command.execute()?; + #[cfg(not(target_os = "windows"))] assert!(stdout.starts_with("foo")); + #[cfg(target_os = "windows")] + assert!(stdout.is_empty()); assert!(stderr.is_empty()); Ok(()) } @@ -382,7 +393,7 @@ mod test { #[cfg(target_os = "windows")] let mut command = tokio::process::Command::new("cmd"); #[cfg(target_os = "windows")] - command.args(&["/C", "echo foo"]); + command.args(["/C", "echo foo"]); let (stdout, stderr) = command.execute(None).await?; assert!(stdout.starts_with("foo")); diff --git a/postgresql_commands/src/vacuumdb.rs b/postgresql_commands/src/vacuumdb.rs index 48f71e5..31407c4 100644 --- a/postgresql_commands/src/vacuumdb.rs +++ b/postgresql_commands/src/vacuumdb.rs @@ -511,8 +511,13 @@ mod tests { #[test] fn test_builder_from() { let command = VacuumDbBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./vacuumdb" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\vacuumdb" "#; + assert_eq!( - r#"PGPASSWORD="password" "./vacuumdb" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -556,9 +561,13 @@ mod tests { .pg_password("password") .maintenance_db("maintenance_db") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "vacuumdb" "--all" "--buffer-usage-limit" "buffer_usage_limit" "--dbname" "dbname" "--disable-page-skipping" "--echo" "--full" "--freeze" "--force-index-cleanup" "--jobs" "1" "--min-mxid-age" "min_mxid_age" "--min-xid-age" "min_xid_age" "--no-index-cleanup" "--no-process-main" "--no-process-toast" "--no-truncate" "--schema" "schema" "--exclude-schema" "exclude_schema" "--parallel" "1" "--quiet" "--skip-locked" "--table" "table" "--verbose" "--version" "--analyze" "--analyze-only" "--analyze-in-stages" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db""#, + format!(r#"{command_prefix}"vacuumdb" "--all" "--buffer-usage-limit" "buffer_usage_limit" "--dbname" "dbname" "--disable-page-skipping" "--echo" "--full" "--freeze" "--force-index-cleanup" "--jobs" "1" "--min-mxid-age" "min_mxid_age" "--min-xid-age" "min_xid_age" "--no-index-cleanup" "--no-process-main" "--no-process-toast" "--no-truncate" "--schema" "schema" "--exclude-schema" "exclude_schema" "--parallel" "1" "--quiet" "--skip-locked" "--table" "table" "--verbose" "--version" "--analyze" "--analyze-only" "--analyze-in-stages" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db""#), command.to_command_string() ); } diff --git a/postgresql_commands/src/vacuumlo.rs b/postgresql_commands/src/vacuumlo.rs index 90d2d37..0573fc5 100644 --- a/postgresql_commands/src/vacuumlo.rs +++ b/postgresql_commands/src/vacuumlo.rs @@ -224,8 +224,13 @@ mod tests { #[test] fn test_builder_from() { let command = VacuumLoBuilder::from(&TestSettings).build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGPASSWORD="password" "./vacuumlo" "#; + #[cfg(target_os = "windows")] + let command_prefix = r#"".\\vacuumlo" "#; + assert_eq!( - r#"PGPASSWORD="password" "./vacuumlo" "--host" "localhost" "--port" "5432" "--username" "postgres""#, + format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), command.to_command_string() ); } @@ -246,9 +251,13 @@ mod tests { .password() .pg_password("password") .build(); + #[cfg(not(target_os = "windows"))] + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; + #[cfg(target_os = "windows")] + let command_prefix = String::new(); assert_eq!( - r#"PGDATABASE="database" PGPASSWORD="password" "vacuumlo" "--limit" "100" "--dry-run" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#, + format!(r#"{command_prefix}"vacuumlo" "--limit" "100" "--dry-run" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#), command.to_command_string() ); } diff --git a/postgresql_embedded/src/lib.rs b/postgresql_embedded/src/lib.rs index 3373b4e..49f0152 100644 --- a/postgresql_embedded/src/lib.rs +++ b/postgresql_embedded/src/lib.rs @@ -147,3 +147,6 @@ lazy_static::lazy_static! { )] pub static ref V12: VersionReq = VersionReq::parse("=12").unwrap(); } + +pub use settings::BOOTSTRAP_SUPERUSER; +pub use settings::BOOTSTRAP_DATABASE; diff --git a/postgresql_embedded/tests/start_config.rs b/postgresql_embedded/tests/start_config.rs index 813156e..264dd30 100644 --- a/postgresql_embedded/tests/start_config.rs +++ b/postgresql_embedded/tests/start_config.rs @@ -1,7 +1,6 @@ -use postgresql_commands::psql::PsqlBuilder; -use postgresql_commands::{CommandBuilder, CommandExecutor}; -use postgresql_embedded::{PostgreSQL, Settings}; +use postgresql_embedded::{BOOTSTRAP_DATABASE, PostgreSQL, Settings}; use std::collections::HashMap; +use sqlx::{PgPool, Row}; use test_log::test; #[test(tokio::test)] @@ -16,16 +15,16 @@ async fn start_config() -> anyhow::Result<()> { postgresql.setup().await?; postgresql.start().await?; let settings = postgresql.settings(); + let database_url = settings.url(BOOTSTRAP_DATABASE); + let pool = PgPool::connect(database_url.as_str()).await?; + let row = sqlx::query("SELECT setting FROM pg_settings WHERE name = $1") + .bind("max_connections".to_string()) + .fetch_one(&pool) + .await?; + let max_connections: String = row.get(0); + pool.close().await; - let mut psql = PsqlBuilder::from(settings) - .command("SELECT setting FROM pg_settings WHERE name = 'max_connections'") - .no_psqlrc() - .no_align() - .tuples_only() - .build(); - let (stdout, _stderr) = psql.execute()?; - - assert!(stdout.contains("42")); + assert_eq!("42".to_string(), max_connections); Ok(()) } From 33a71213b593d6b06b744e69798607ca5d1da4be Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 19:12:53 -0600 Subject: [PATCH 05/11] build: correct formatting --- postgresql_commands/src/clusterdb.rs | 8 ++++++-- postgresql_commands/src/createdb.rs | 8 ++++++-- postgresql_commands/src/createuser.rs | 8 ++++++-- postgresql_commands/src/dropdb.rs | 8 ++++++-- postgresql_commands/src/dropuser.rs | 8 ++++++-- postgresql_commands/src/ecpg.rs | 4 +++- postgresql_commands/src/initdb.rs | 4 +++- postgresql_commands/src/oid2name.rs | 8 ++++++-- postgresql_commands/src/pg_amcheck.rs | 8 ++++++-- postgresql_commands/src/pg_archivecleanup.rs | 4 +++- postgresql_commands/src/pg_basebackup.rs | 8 ++++++-- postgresql_commands/src/pg_checksums.rs | 4 +++- postgresql_commands/src/pg_config.rs | 4 +++- postgresql_commands/src/pg_ctl.rs | 4 +++- postgresql_commands/src/pg_dump.rs | 8 ++++++-- postgresql_commands/src/pg_dumpall.rs | 8 ++++++-- postgresql_commands/src/pg_isready.rs | 8 ++++++-- postgresql_commands/src/pg_receivewal.rs | 8 ++++++-- postgresql_commands/src/pg_recvlogical.rs | 8 ++++++-- postgresql_commands/src/pg_resetwal.rs | 4 +++- postgresql_commands/src/pg_restore.rs | 8 ++++++-- postgresql_commands/src/pg_rewind.rs | 4 +++- postgresql_commands/src/pg_upgrade.rs | 4 +++- postgresql_commands/src/pg_verifybackup.rs | 4 +++- postgresql_commands/src/pg_waldump.rs | 4 +++- postgresql_commands/src/pgbench.rs | 8 ++++++-- postgresql_commands/src/postgres.rs | 4 +++- postgresql_commands/src/psql.rs | 8 ++++++-- postgresql_commands/src/reindexdb.rs | 8 ++++++-- postgresql_commands/src/traits.rs | 5 ++++- postgresql_commands/src/vacuumdb.rs | 8 ++++++-- postgresql_commands/src/vacuumlo.rs | 8 ++++++-- postgresql_embedded/src/lib.rs | 2 +- postgresql_embedded/tests/start_config.rs | 4 ++-- 34 files changed, 157 insertions(+), 54 deletions(-) diff --git a/postgresql_commands/src/clusterdb.rs b/postgresql_commands/src/clusterdb.rs index a5bed37..26ccfaa 100644 --- a/postgresql_commands/src/clusterdb.rs +++ b/postgresql_commands/src/clusterdb.rs @@ -280,7 +280,9 @@ mod tests { let command_prefix = r#"".\\clusterdb" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -311,7 +313,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"clusterdb" "--all" "--dbname" "dbname" "--echo" "--quiet" "--table" "table" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres""#), + format!( + r#"{command_prefix}"clusterdb" "--all" "--dbname" "dbname" "--echo" "--quiet" "--table" "table" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/createdb.rs b/postgresql_commands/src/createdb.rs index 22bb532..ea5b869 100644 --- a/postgresql_commands/src/createdb.rs +++ b/postgresql_commands/src/createdb.rs @@ -385,7 +385,9 @@ mod tests { let command_prefix = r#"".\\createdb" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -424,7 +426,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"createdb" "--tablespace" "pg_default" "--echo" "--encoding" "UTF8" "--locale" "en_US.UTF-8" "--lc-collate" "en_US.UTF-8" "--lc-ctype" "en_US.UTF-8" "--icu-locale" "en_US" "--icu-rules" "standard" "--locale-provider" "icu" "--owner" "postgres" "--strategy" "wal_log" "--template" "template0" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "testdb" "Test Database""#), + format!( + r#"{command_prefix}"createdb" "--tablespace" "pg_default" "--echo" "--encoding" "UTF8" "--locale" "en_US.UTF-8" "--lc-collate" "en_US.UTF-8" "--lc-ctype" "en_US.UTF-8" "--icu-locale" "en_US" "--icu-rules" "standard" "--locale-provider" "icu" "--owner" "postgres" "--strategy" "wal_log" "--template" "template0" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "testdb" "Test Database""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/createuser.rs b/postgresql_commands/src/createuser.rs index b19c2e6..53a2923 100644 --- a/postgresql_commands/src/createuser.rs +++ b/postgresql_commands/src/createuser.rs @@ -462,7 +462,9 @@ mod tests { let command_prefix = r#"".\\createuser" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -508,7 +510,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"createuser" "--with-admin" "admin" "--connection-limit" "10" "--createdb" "--no-createdb" "--echo" "--member-of" "member" "--inherit" "--no-inherit" "--login" "--no-login" "--with-member" "member" "--pwprompt" "--createrole" "--no-createrole" "--superuser" "--no-superuser" "--valid-until" "2021-12-31" "--version" "--interactive" "--bypassrls" "--no-bypassrls" "--replication" "--no-replication" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""#), + format!( + r#"{command_prefix}"createuser" "--with-admin" "admin" "--connection-limit" "10" "--createdb" "--no-createdb" "--echo" "--member-of" "member" "--inherit" "--no-inherit" "--login" "--no-login" "--with-member" "member" "--pwprompt" "--createrole" "--no-createrole" "--superuser" "--no-superuser" "--valid-until" "2021-12-31" "--version" "--interactive" "--bypassrls" "--no-bypassrls" "--replication" "--no-replication" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/dropdb.rs b/postgresql_commands/src/dropdb.rs index f7a92ad..6cdb301 100644 --- a/postgresql_commands/src/dropdb.rs +++ b/postgresql_commands/src/dropdb.rs @@ -265,7 +265,9 @@ mod tests { let command_prefix = r#"".\\dropdb" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -295,7 +297,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"dropdb" "--echo" "--force" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "dbname""#), + format!( + r#"{command_prefix}"dropdb" "--echo" "--force" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--maintenance-db" "postgres" "dbname""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/dropuser.rs b/postgresql_commands/src/dropuser.rs index df135ff..224b662 100644 --- a/postgresql_commands/src/dropuser.rs +++ b/postgresql_commands/src/dropuser.rs @@ -229,7 +229,9 @@ mod tests { let command_prefix = r#"".\\dropuser" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -256,7 +258,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"dropuser" "--echo" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#), + format!( + r#"{command_prefix}"dropuser" "--echo" "--interactive" "--version" "--if-exists" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/ecpg.rs b/postgresql_commands/src/ecpg.rs index 53317de..daa91e8 100644 --- a/postgresql_commands/src/ecpg.rs +++ b/postgresql_commands/src/ecpg.rs @@ -261,7 +261,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"ecpg" "-c" "-C" "mode" "-D" "symbol" "-h" "-i" "-I" "directory" "-o" "outfile" "-r" "behavior" "--regression" "-t" "--version" "--help""#), + format!( + r#"{command_prefix}"ecpg" "-c" "-C" "mode" "-D" "symbol" "-h" "-i" "-I" "directory" "-o" "outfile" "-r" "behavior" "--regression" "-t" "--version" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/initdb.rs b/postgresql_commands/src/initdb.rs index 0cf1f38..a1b2070 100644 --- a/postgresql_commands/src/initdb.rs +++ b/postgresql_commands/src/initdb.rs @@ -583,7 +583,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"initdb" "--auth" "md5" "--auth-host" "md5" "--auth-local" "md5" "--pgdata" "pgdata" "--encoding" "UTF8" "--allow-group-access" "--icu-locale" "en_US" "--icu-rules" "phonebook" "--data-checksums" "--locale" "en_US" "--lc-collate" "en_US" "--lc-ctype" "en_US" "--lc-messages" "en_US" "--lc-monetary" "en_US" "--lc-numeric" "en_US" "--lc-time" "en_US" "--no-locale" "--locale-provider" "icu" "--pwfile" ".pwfile" "--text-search-config" "english" "--username" "postgres" "--pwprompt" "--waldir" "waldir" "--wal-segsize" "1" "--set" "timezone=UTC" "--debug" "--discard-caches" "--directory" "directory" "--no-clean" "--no-sync" "--no-instructions" "--show" "--sync-only" "--version" "--help""#), + format!( + r#"{command_prefix}"initdb" "--auth" "md5" "--auth-host" "md5" "--auth-local" "md5" "--pgdata" "pgdata" "--encoding" "UTF8" "--allow-group-access" "--icu-locale" "en_US" "--icu-rules" "phonebook" "--data-checksums" "--locale" "en_US" "--lc-collate" "en_US" "--lc-ctype" "en_US" "--lc-messages" "en_US" "--lc-monetary" "en_US" "--lc-numeric" "en_US" "--lc-time" "en_US" "--no-locale" "--locale-provider" "icu" "--pwfile" ".pwfile" "--text-search-config" "english" "--username" "postgres" "--pwprompt" "--waldir" "waldir" "--wal-segsize" "1" "--set" "timezone=UTC" "--debug" "--discard-caches" "--directory" "directory" "--no-clean" "--no-sync" "--no-instructions" "--show" "--sync-only" "--version" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/oid2name.rs b/postgresql_commands/src/oid2name.rs index 5fb03bd..349027a 100644 --- a/postgresql_commands/src/oid2name.rs +++ b/postgresql_commands/src/oid2name.rs @@ -266,7 +266,9 @@ mod tests { let command_prefix = r#"".\\oid2name" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -296,7 +298,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"oid2name" "--filenode" "filenode" "--indexes" "--oid" "oid" "--quiet" "--tablespaces" "--system-objects" "--table" "table" "--version" "--extended" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username""#), + format!( + r#"{command_prefix}"oid2name" "--filenode" "filenode" "--indexes" "--oid" "oid" "--quiet" "--tablespaces" "--system-objects" "--table" "table" "--version" "--extended" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_amcheck.rs b/postgresql_commands/src/pg_amcheck.rs index 065fae8..5d73a34 100644 --- a/postgresql_commands/src/pg_amcheck.rs +++ b/postgresql_commands/src/pg_amcheck.rs @@ -545,7 +545,9 @@ mod tests { let command_prefix = r#"".\\pg_amcheck" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -597,7 +599,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_amcheck" "--all" "--database" "database" "--exclude-database" "exclude_database" "--index" "index" "--exclude-index" "exclude_index" "--relation" "relation" "--exclude-relation" "exclude_relation" "--schema" "schema" "--exclude-schema" "exclude_schema" "--table" "table" "--exclude-table" "exclude_table" "--no-dependent-indexes" "--no-dependent-toast" "--no-strict-names" "--exclude-toast-pointers" "--on-error-stop" "--skip" "skip" "--startblock" "start_block" "--endblock" "end_block" "--heapallindexed" "--parent-check" "--rootdescend" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db" "--echo" "--jobs" "jobs" "--progress" "--verbose" "--version" "--install-missing" "--help""#), + format!( + r#"{command_prefix}"pg_amcheck" "--all" "--database" "database" "--exclude-database" "exclude_database" "--index" "index" "--exclude-index" "exclude_index" "--relation" "relation" "--exclude-relation" "exclude_relation" "--schema" "schema" "--exclude-schema" "exclude_schema" "--table" "table" "--exclude-table" "exclude_table" "--no-dependent-indexes" "--no-dependent-toast" "--no-strict-names" "--exclude-toast-pointers" "--on-error-stop" "--skip" "skip" "--startblock" "start_block" "--endblock" "end_block" "--heapallindexed" "--parent-check" "--rootdescend" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db" "--echo" "--jobs" "jobs" "--progress" "--verbose" "--version" "--install-missing" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_archivecleanup.rs b/postgresql_commands/src/pg_archivecleanup.rs index 7b76a69..8dccd11 100644 --- a/postgresql_commands/src/pg_archivecleanup.rs +++ b/postgresql_commands/src/pg_archivecleanup.rs @@ -192,7 +192,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_archivecleanup" "-d" "-n" "--version" "-x" "partial" "--help" "archive_location" "000000010000000000000001""#), + format!( + r#"{command_prefix}"pg_archivecleanup" "-d" "-n" "--version" "-x" "partial" "--help" "archive_location" "000000010000000000000001""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_basebackup.rs b/postgresql_commands/src/pg_basebackup.rs index a998e28..b33b759 100644 --- a/postgresql_commands/src/pg_basebackup.rs +++ b/postgresql_commands/src/pg_basebackup.rs @@ -520,7 +520,9 @@ mod tests { let command_prefix = r#"".\\pg_basebackup" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -570,7 +572,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_basebackup" "--pgdata" "pgdata" "--format" "plain" "--max-rate" "100M" "--write-recovery-conf" "--target" "localhost" "--tablespace-mapping" "tablespace_mapping" "--waldir" "waldir" "--wal-method" "stream" "--gzip" "--compress" "client" "--checkpoint" "fast" "--create-slot" "--label" "my_backup" "--no-clean" "--no-sync" "--progress" "--slot" "my_slot" "--verbose" "--version" "--manifest-checksums" "sha256" "--manifest-force-encode" "--no-estimate-size" "--no-manifest" "--no-slot" "--no-verify-checksums" "--help" "--dbname" "postgres" "--host" "localhost" "--port" "5432" "--status-interval" "10" "--username" "postgres" "--no-password" "--password""#), + format!( + r#"{command_prefix}"pg_basebackup" "--pgdata" "pgdata" "--format" "plain" "--max-rate" "100M" "--write-recovery-conf" "--target" "localhost" "--tablespace-mapping" "tablespace_mapping" "--waldir" "waldir" "--wal-method" "stream" "--gzip" "--compress" "client" "--checkpoint" "fast" "--create-slot" "--label" "my_backup" "--no-clean" "--no-sync" "--progress" "--slot" "my_slot" "--verbose" "--version" "--manifest-checksums" "sha256" "--manifest-force-encode" "--no-estimate-size" "--no-manifest" "--no-slot" "--no-verify-checksums" "--help" "--dbname" "postgres" "--host" "localhost" "--port" "5432" "--status-interval" "10" "--username" "postgres" "--no-password" "--password""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_checksums.rs b/postgresql_commands/src/pg_checksums.rs index ef311a9..7e6dd35 100644 --- a/postgresql_commands/src/pg_checksums.rs +++ b/postgresql_commands/src/pg_checksums.rs @@ -232,7 +232,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_checksums" "--pgdata" "pgdata" "--check" "--disable" "--enable" "--filenode" "12345" "--no-sync" "--progress" "--verbose" "--version" "--help""#), + format!( + r#"{command_prefix}"pg_checksums" "--pgdata" "pgdata" "--check" "--disable" "--enable" "--filenode" "12345" "--no-sync" "--progress" "--verbose" "--version" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_config.rs b/postgresql_commands/src/pg_config.rs index 5e38e47..d5521d3 100644 --- a/postgresql_commands/src/pg_config.rs +++ b/postgresql_commands/src/pg_config.rs @@ -425,7 +425,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_config" "--bindir" "bindir" "--docdir" "docdir" "--htmldir" "htmldir" "--includedir" "includedir" "--pkgincludedir" "pkgincludedir" "--includedir-server" "includedir_server" "--libdir" "libdir" "--pkglibdir" "pkglibdir" "--localedir" "localedir" "--mandir" "mandir" "--sharedir" "sharedir" "--sysconfdir" "sysconfdir" "--pgxs" "pgxs" "--configure" "--cc" "--cppflags" "--cflags" "--cflags_sl" "--ldflags" "--ldflags_ex" "--ldflags_sl" "--libs" "--version" "--help""#), + format!( + r#"{command_prefix}"pg_config" "--bindir" "bindir" "--docdir" "docdir" "--htmldir" "htmldir" "--includedir" "includedir" "--pkgincludedir" "pkgincludedir" "--includedir-server" "includedir_server" "--libdir" "libdir" "--pkglibdir" "pkglibdir" "--localedir" "localedir" "--mandir" "mandir" "--sharedir" "sharedir" "--sysconfdir" "sysconfdir" "--pgxs" "pgxs" "--configure" "--cc" "--cppflags" "--cflags" "--cflags_sl" "--ldflags" "--ldflags_ex" "--ldflags_sl" "--libs" "--version" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_ctl.rs b/postgresql_commands/src/pg_ctl.rs index 6646562..5d2ec2f 100644 --- a/postgresql_commands/src/pg_ctl.rs +++ b/postgresql_commands/src/pg_ctl.rs @@ -368,7 +368,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_ctl" "start" "--pgdata" "pgdata" "--silent" "--timeout" "60" "--version" "--wait" "--no-wait" "--help" "--core-files" "--log" "log" "-o" "-c log_connections=on" "-p" "path_to_postgres" "--mode" "smart" "HUP" "12345""#), + format!( + r#"{command_prefix}"pg_ctl" "start" "--pgdata" "pgdata" "--silent" "--timeout" "60" "--version" "--wait" "--no-wait" "--help" "--core-files" "--log" "log" "-o" "-c log_connections=on" "-p" "path_to_postgres" "--mode" "smart" "HUP" "12345""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_dump.rs b/postgresql_commands/src/pg_dump.rs index 18003a2..a8bfce5 100644 --- a/postgresql_commands/src/pg_dump.rs +++ b/postgresql_commands/src/pg_dump.rs @@ -855,7 +855,9 @@ mod tests { let command_prefix = r#"".\\pg_dump" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -932,7 +934,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_dump" "--data-only" "--large-objects" "--no-large-objects" "--clean" "--create" "--extension" "extension" "--encoding" "UTF8" "--file" "file" "--format" "format" "--jobs" "jobs" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--no-reconnect" "--schema-only" "--superuser" "superuser" "--table" "table" "--exclude-table" "exclude_table" "--verbose" "--version" "--no-privileges" "--compression" "compression" "--binary-upgrade" "--column-inserts" "--attribute-inserts" "--disable-dollar-quoting" "--disable-triggers" "--enable-row-security" "--exclude-table-data-and-children" "exclude_table_data_and_children" "--extra-float-digits" "extra_float_digits" "--if-exists" "--include-foreign-data" "include_foreign_data" "--inserts" "--load-via-partition-root" "--lock-wait-timeout" "10" "--no-comments" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "100" "--section" "section" "--serializable-deferrable" "--snapshot" "snapshot" "--strict-names" "--table-and-children" "table_and_children" "--use-set-session-authorization" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "role""#), + format!( + r#"{command_prefix}"pg_dump" "--data-only" "--large-objects" "--no-large-objects" "--clean" "--create" "--extension" "extension" "--encoding" "UTF8" "--file" "file" "--format" "format" "--jobs" "jobs" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--no-reconnect" "--schema-only" "--superuser" "superuser" "--table" "table" "--exclude-table" "exclude_table" "--verbose" "--version" "--no-privileges" "--compression" "compression" "--binary-upgrade" "--column-inserts" "--attribute-inserts" "--disable-dollar-quoting" "--disable-triggers" "--enable-row-security" "--exclude-table-data-and-children" "exclude_table_data_and_children" "--extra-float-digits" "extra_float_digits" "--if-exists" "--include-foreign-data" "include_foreign_data" "--inserts" "--load-via-partition-root" "--lock-wait-timeout" "10" "--no-comments" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "100" "--section" "section" "--serializable-deferrable" "--snapshot" "snapshot" "--strict-names" "--table-and-children" "table_and_children" "--use-set-session-authorization" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "role""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_dumpall.rs b/postgresql_commands/src/pg_dumpall.rs index 7a59f26..40834cd 100644 --- a/postgresql_commands/src/pg_dumpall.rs +++ b/postgresql_commands/src/pg_dumpall.rs @@ -672,7 +672,9 @@ mod tests { let command_prefix = r#"".\\pg_dumpall" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -735,7 +737,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_dumpall" "--file" "dump.sql" "--verbose" "--version" "--lock-wait-timeout" "10" "--help" "--data-only" "--clean" "--encoding" "UTF8" "--globals-only" "--no-owner" "--roles-only" "--schema-only" "--superuser" "postgres" "--tablespaces-only" "--no-privileges" "--binary-upgrade" "--column-inserts" "--disable-dollar-quoting" "--disable-triggers" "--exclude-database" "exclude" "--extra-float-digits" "2" "--if-exists" "--inserts" "--load-via-partition-root" "--no-comments" "--no-publications" "--no-role-passwords" "--no-security-labels" "--no-subscriptions" "--no-sync" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "1000" "--use-set-session-authorization" "--dbname" "postgres" "--host" "localhost" "--database" "postgres" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "postgres""#), + format!( + r#"{command_prefix}"pg_dumpall" "--file" "dump.sql" "--verbose" "--version" "--lock-wait-timeout" "10" "--help" "--data-only" "--clean" "--encoding" "UTF8" "--globals-only" "--no-owner" "--roles-only" "--schema-only" "--superuser" "postgres" "--tablespaces-only" "--no-privileges" "--binary-upgrade" "--column-inserts" "--disable-dollar-quoting" "--disable-triggers" "--exclude-database" "exclude" "--extra-float-digits" "2" "--if-exists" "--inserts" "--load-via-partition-root" "--no-comments" "--no-publications" "--no-role-passwords" "--no-security-labels" "--no-subscriptions" "--no-sync" "--no-table-access-method" "--no-tablespaces" "--no-toast-compression" "--no-unlogged-table-data" "--on-conflict-do-nothing" "--quote-all-identifiers" "--rows-per-insert" "1000" "--use-set-session-authorization" "--dbname" "postgres" "--host" "localhost" "--database" "postgres" "--port" "5432" "--username" "postgres" "--no-password" "--password" "--role" "postgres""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_isready.rs b/postgresql_commands/src/pg_isready.rs index b183d27..da2c27c 100644 --- a/postgresql_commands/src/pg_isready.rs +++ b/postgresql_commands/src/pg_isready.rs @@ -192,7 +192,9 @@ mod tests { let command_prefix = r#"".\\pg_isready" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -216,7 +218,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_isready" "--dbname" "postgres" "--quiet" "--version" "--help" "--host" "localhost" "--port" "5432" "--timeout" "3" "--username" "postgres""#), + format!( + r#"{command_prefix}"pg_isready" "--dbname" "postgres" "--quiet" "--version" "--help" "--host" "localhost" "--port" "5432" "--timeout" "3" "--username" "postgres""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_receivewal.rs b/postgresql_commands/src/pg_receivewal.rs index c3436e4..1f1d367 100644 --- a/postgresql_commands/src/pg_receivewal.rs +++ b/postgresql_commands/src/pg_receivewal.rs @@ -355,7 +355,9 @@ mod tests { let command_prefix = r#"".\\pg_receivewal" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -392,7 +394,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_receivewal" "--directory" "directory" "--endpos" "endpos" "--if-not-exists" "--no-loop" "--no-sync" "--status-interval" "status_interval" "--slot" "slot" "--synchronous" "--verbose" "--version" "--compress" "compress" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--create-slot" "--drop-slot""#), + format!( + r#"{command_prefix}"pg_receivewal" "--directory" "directory" "--endpos" "endpos" "--if-not-exists" "--no-loop" "--no-sync" "--status-interval" "status_interval" "--slot" "slot" "--synchronous" "--verbose" "--version" "--compress" "compress" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--create-slot" "--drop-slot""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_recvlogical.rs b/postgresql_commands/src/pg_recvlogical.rs index 44a9590..7aab95f 100644 --- a/postgresql_commands/src/pg_recvlogical.rs +++ b/postgresql_commands/src/pg_recvlogical.rs @@ -394,7 +394,9 @@ mod tests { let command_prefix = r#"".\\pg_recvlogical" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -434,7 +436,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_recvlogical" "--create-slot" "--drop-slot" "--start" "--endpos" "endpos" "--file" "file" "--fsync-interval" "fsync_interval" "--if-not-exists" "--startpos" "startpos" "--no-loop" "--option" "option" "--plugin" "plugin" "--status-interval" "status_interval" "--slot" "slot" "--two-phase" "--verbose" "--version" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""#), + format!( + r#"{command_prefix}"pg_recvlogical" "--create-slot" "--drop-slot" "--start" "--endpos" "endpos" "--file" "file" "--fsync-interval" "fsync_interval" "--if-not-exists" "--startpos" "startpos" "--no-loop" "--option" "option" "--plugin" "plugin" "--status-interval" "status_interval" "--slot" "slot" "--two-phase" "--verbose" "--version" "--help" "--dbname" "dbname" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_resetwal.rs b/postgresql_commands/src/pg_resetwal.rs index 1b768cb..cfedc45 100644 --- a/postgresql_commands/src/pg_resetwal.rs +++ b/postgresql_commands/src/pg_resetwal.rs @@ -292,7 +292,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_resetwal" "--commit-timestamp-ids" "1,2" "--pgdata" "pgdata" "--epoch" "epoch" "--force" "--next-wal-file" "next_wal_file" "--multixact-ids" "3,4" "--dry-run" "--next-oid" "next_oid" "--multixact-offset" "multixact_offset" "--oldest-transaction-id" "oldest_transaction_id" "--version" "--next-transaction-id" "next_transaction_id" "--wal-segsize" "wal_segsize" "--help""#), + format!( + r#"{command_prefix}"pg_resetwal" "--commit-timestamp-ids" "1,2" "--pgdata" "pgdata" "--epoch" "epoch" "--force" "--next-wal-file" "next_wal_file" "--multixact-ids" "3,4" "--dry-run" "--next-oid" "next_oid" "--multixact-offset" "multixact_offset" "--oldest-transaction-id" "oldest_transaction_id" "--version" "--next-transaction-id" "next_transaction_id" "--wal-segsize" "wal_segsize" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_restore.rs b/postgresql_commands/src/pg_restore.rs index b4e0719..6b40423 100644 --- a/postgresql_commands/src/pg_restore.rs +++ b/postgresql_commands/src/pg_restore.rs @@ -640,7 +640,9 @@ mod tests { let command_prefix = r#"".\\pg_restore" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -700,7 +702,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_restore" "--dbname" "dbname" "--file" "file" "--format" "format" "--list" "--verbose" "--version" "--help" "--data-only" "--clean" "--create" "--exit-on-error" "--index" "index" "--jobs" "jobs" "--use-list" "use_list" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--function" "function" "--schema-only" "--superuser" "superuser" "--table" "table" "--trigger" "trigger" "--no-privileges" "--single-transaction" "--disable-triggers" "--enable-row-security" "--if-exists" "--no-comments" "--no-data-for-failed-tables" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--section" "section" "--strict-names" "--use-set-session-authorization" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--role" "role""#), + format!( + r#"{command_prefix}"pg_restore" "--dbname" "dbname" "--file" "file" "--format" "format" "--list" "--verbose" "--version" "--help" "--data-only" "--clean" "--create" "--exit-on-error" "--index" "index" "--jobs" "jobs" "--use-list" "use_list" "--schema" "schema" "--exclude-schema" "exclude_schema" "--no-owner" "--function" "function" "--schema-only" "--superuser" "superuser" "--table" "table" "--trigger" "trigger" "--no-privileges" "--single-transaction" "--disable-triggers" "--enable-row-security" "--if-exists" "--no-comments" "--no-data-for-failed-tables" "--no-publications" "--no-security-labels" "--no-subscriptions" "--no-table-access-method" "--no-tablespaces" "--section" "section" "--strict-names" "--use-set-session-authorization" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--role" "role""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_rewind.rs b/postgresql_commands/src/pg_rewind.rs index 4186f2c..aa3816b 100644 --- a/postgresql_commands/src/pg_rewind.rs +++ b/postgresql_commands/src/pg_rewind.rs @@ -273,7 +273,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_rewind" "--restore-target-wal" "--target-pgdata" "target_pgdata" "--source-pgdata" "source_pgdata" "--source-server" "source_server" "--dry-run" "--no-sync" "--progress" "--write-recovery-conf" "--config-file" "config_file" "--debug" "--no-ensure-shutdown" "--version" "--help""#), + format!( + r#"{command_prefix}"pg_rewind" "--restore-target-wal" "--target-pgdata" "target_pgdata" "--source-pgdata" "source_pgdata" "--source-server" "source_server" "--dry-run" "--no-sync" "--progress" "--write-recovery-conf" "--config-file" "config_file" "--debug" "--no-ensure-shutdown" "--version" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_upgrade.rs b/postgresql_commands/src/pg_upgrade.rs index 70e51ef..61baa24 100644 --- a/postgresql_commands/src/pg_upgrade.rs +++ b/postgresql_commands/src/pg_upgrade.rs @@ -371,7 +371,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_upgrade" "--old-bindir" "old" "--new-bindir" "new" "--check" "--old-datadir" "old_data" "--new-datadir" "new_data" "--jobs" "10" "--link" "--no-sync" "--old-options" "old" "--new-options" "new" "--old-port" "5432" "--new-port" "5433" "--retain" "--socketdir" "socket" "--username" "user" "--verbose" "--version" "--clone" "--copy" "--help""#), + format!( + r#"{command_prefix}"pg_upgrade" "--old-bindir" "old" "--new-bindir" "new" "--check" "--old-datadir" "old_data" "--new-datadir" "new_data" "--jobs" "10" "--link" "--no-sync" "--old-options" "old" "--new-options" "new" "--old-port" "5432" "--new-port" "5433" "--retain" "--socketdir" "socket" "--username" "user" "--verbose" "--version" "--clone" "--copy" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_verifybackup.rs b/postgresql_commands/src/pg_verifybackup.rs index da0de1e..ef15b68 100644 --- a/postgresql_commands/src/pg_verifybackup.rs +++ b/postgresql_commands/src/pg_verifybackup.rs @@ -233,7 +233,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_verifybackup" "--exit-on-error" "--ignore" "ignore" "--manifest-path" "manifest-path" "--no-parse-wal" "--progress" "--quiet" "--skip-checksums" "--wal-directory" "wal_directory" "--version" "--help""#), + format!( + r#"{command_prefix}"pg_verifybackup" "--exit-on-error" "--ignore" "ignore" "--manifest-path" "manifest-path" "--no-parse-wal" "--progress" "--quiet" "--skip-checksums" "--wal-directory" "wal_directory" "--version" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pg_waldump.rs b/postgresql_commands/src/pg_waldump.rs index eff020d..24449af 100644 --- a/postgresql_commands/src/pg_waldump.rs +++ b/postgresql_commands/src/pg_waldump.rs @@ -346,7 +346,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pg_waldump" "--bkp-details" "--block" "block" "--end" "end" "--follow" "--fork" "fork" "--limit" "limit" "--path" "path" "--quiet" "--rmgr" "rmgr" "--relation" "relation" "--start" "start" "--timeline" "timeline" "--version" "--fullpage" "--xid" "xid" "--stats" "stats" "--save-fullpage" "save_fullpage" "--help""#), + format!( + r#"{command_prefix}"pg_waldump" "--bkp-details" "--block" "block" "--end" "end" "--follow" "--fork" "fork" "--limit" "limit" "--path" "path" "--quiet" "--rmgr" "rmgr" "--relation" "relation" "--start" "start" "--timeline" "timeline" "--version" "--fullpage" "--xid" "xid" "--stats" "stats" "--save-fullpage" "save_fullpage" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/pgbench.rs b/postgresql_commands/src/pgbench.rs index b06be9b..0e946b7 100644 --- a/postgresql_commands/src/pgbench.rs +++ b/postgresql_commands/src/pgbench.rs @@ -672,7 +672,9 @@ mod tests { let command_prefix = r#"".\\pgbench" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -734,7 +736,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"pgbench" "--initialize" "--init-steps" "steps" "--fillfactor" "10" "--no-vacuum" "--quiet" "--scale" "10" "--foreign-keys" "--index-tablespace" "tablespace" "--partition-method" "method" "--partitions" "10" "--tablespace" "tablespace" "--unlogged-tables" "--builtin" "name" "--file" "filename" "--skip-some-updates" "--select-only" "--client" "10" "--connect" "--define" "var" "--jobs" "10" "--log" "--latency-limit" "10" "--protocol" "protocol" "--no-vacuum" "--progress" "10" "--report-per-command" "--rate" "10" "--scale" "10" "--transactions" "10" "--time" "10" "--vacuum-all" "--aggregate-interval" "10" "--failures-detailed" "--log-prefix" "prefix" "--max-tries" "10" "--progress-timestamp" "--random-seed" "seed" "--sampling-rate" "10" "--show-script" "name" "--verbose-errors" "--debug" "--host" "localhost" "--port" "5432" "--username" "username" "--version" "--help""#), + format!( + r#"{command_prefix}"pgbench" "--initialize" "--init-steps" "steps" "--fillfactor" "10" "--no-vacuum" "--quiet" "--scale" "10" "--foreign-keys" "--index-tablespace" "tablespace" "--partition-method" "method" "--partitions" "10" "--tablespace" "tablespace" "--unlogged-tables" "--builtin" "name" "--file" "filename" "--skip-some-updates" "--select-only" "--client" "10" "--connect" "--define" "var" "--jobs" "10" "--log" "--latency-limit" "10" "--protocol" "protocol" "--no-vacuum" "--progress" "10" "--report-per-command" "--rate" "10" "--scale" "10" "--transactions" "10" "--time" "10" "--vacuum-all" "--aggregate-interval" "10" "--failures-detailed" "--log-prefix" "prefix" "--max-tries" "10" "--progress-timestamp" "--random-seed" "seed" "--sampling-rate" "10" "--show-script" "name" "--verbose-errors" "--debug" "--host" "localhost" "--port" "5432" "--username" "username" "--version" "--help""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/postgres.rs b/postgresql_commands/src/postgres.rs index dd183ab..f82d478 100644 --- a/postgresql_commands/src/postgres.rs +++ b/postgresql_commands/src/postgres.rs @@ -524,7 +524,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"postgres" "-B" "100" "-c" "name=value" "-C" "name" "-d" "3" "-D" "data_dir" "-e" "-F" "-h" "localhost" "-i" "-k" "socket_location" "-N" "100" "-p" "5432" "-s" "-S" "100" "--version" "--describe-config" "--help" "-f" "type" "-O" "-P" "-t" "timings" "-T" "-W" "10" "--single" "dbname" "-d" "3" "-E" "-j" "-r" "output_file" "--boot" "--check""#), + format!( + r#"{command_prefix}"postgres" "-B" "100" "-c" "name=value" "-C" "name" "-d" "3" "-D" "data_dir" "-e" "-F" "-h" "localhost" "-i" "-k" "socket_location" "-N" "100" "-p" "5432" "-s" "-S" "100" "--version" "--describe-config" "--help" "-f" "type" "-O" "-P" "-t" "timings" "-T" "-W" "10" "--single" "dbname" "-d" "3" "-E" "-j" "-r" "output_file" "--boot" "--check""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/psql.rs b/postgresql_commands/src/psql.rs index 3fbec02..5ace0fa 100644 --- a/postgresql_commands/src/psql.rs +++ b/postgresql_commands/src/psql.rs @@ -543,7 +543,9 @@ mod tests { let command_prefix = r#"".\\psql" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -595,7 +597,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"psql" "--command" "SELECT * FROM test" "--dbname" "dbname" "--file" "test.sql" "--list" "--variable" "ON_ERROR_STOP=1" "--version" "--no-psqlrc" "--single-transaction" "--help" "options" "--echo-all" "--echo-errors" "--echo-queries" "--echo-hidden" "--log-file" "psql.log" "--no-readline" "--output" "output.txt" "--quiet" "--single-step" "--single-line" "--no-align" "--csv" "--field-separator" "|" "--html" "--pset" "border=1" "--record-separator" "\n" "--tuples-only" "--table-attr" "width=100" "--expanded" "--field-separator-zero" "--record-separator-zero" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#), + format!( + r#"{command_prefix}"psql" "--command" "SELECT * FROM test" "--dbname" "dbname" "--file" "test.sql" "--list" "--variable" "ON_ERROR_STOP=1" "--version" "--no-psqlrc" "--single-transaction" "--help" "options" "--echo-all" "--echo-errors" "--echo-queries" "--echo-hidden" "--log-file" "psql.log" "--no-readline" "--output" "output.txt" "--quiet" "--single-step" "--single-line" "--no-align" "--csv" "--field-separator" "|" "--html" "--pset" "border=1" "--record-separator" "\n" "--tuples-only" "--table-attr" "width=100" "--expanded" "--field-separator-zero" "--record-separator-zero" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/reindexdb.rs b/postgresql_commands/src/reindexdb.rs index 6e490dc..eab5fc4 100644 --- a/postgresql_commands/src/reindexdb.rs +++ b/postgresql_commands/src/reindexdb.rs @@ -355,7 +355,9 @@ mod tests { let command_prefix = r#"".\\reindexdb" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -392,7 +394,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"reindexdb" "--all" "--concurrently" "--dbname" "dbname" "--echo" "--index" "index" "--jobs" "1" "--quiet" "--system" "--schema" "schema" "--table" "table" "--tablespace" "tablespace" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance-db""#), + format!( + r#"{command_prefix}"reindexdb" "--all" "--concurrently" "--dbname" "dbname" "--echo" "--index" "index" "--jobs" "1" "--quiet" "--system" "--schema" "schema" "--table" "table" "--tablespace" "tablespace" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance-db""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/traits.rs b/postgresql_commands/src/traits.rs index 75a5298..3c173a6 100644 --- a/postgresql_commands/src/traits.rs +++ b/postgresql_commands/src/traits.rs @@ -265,7 +265,10 @@ mod test { #[cfg(target_os = "windows")] let command_prefix = String::new(); - assert_eq!(format!(r#"{command_prefix}"test""#), command.to_command_string()); + assert_eq!( + format!(r#"{command_prefix}"test""#), + command.to_command_string() + ); } #[derive(Debug)] diff --git a/postgresql_commands/src/vacuumdb.rs b/postgresql_commands/src/vacuumdb.rs index 31407c4..d4f2cba 100644 --- a/postgresql_commands/src/vacuumdb.rs +++ b/postgresql_commands/src/vacuumdb.rs @@ -517,7 +517,9 @@ mod tests { let command_prefix = r#"".\\vacuumdb" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -567,7 +569,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"vacuumdb" "--all" "--buffer-usage-limit" "buffer_usage_limit" "--dbname" "dbname" "--disable-page-skipping" "--echo" "--full" "--freeze" "--force-index-cleanup" "--jobs" "1" "--min-mxid-age" "min_mxid_age" "--min-xid-age" "min_xid_age" "--no-index-cleanup" "--no-process-main" "--no-process-toast" "--no-truncate" "--schema" "schema" "--exclude-schema" "exclude_schema" "--parallel" "1" "--quiet" "--skip-locked" "--table" "table" "--verbose" "--version" "--analyze" "--analyze-only" "--analyze-in-stages" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db""#), + format!( + r#"{command_prefix}"vacuumdb" "--all" "--buffer-usage-limit" "buffer_usage_limit" "--dbname" "dbname" "--disable-page-skipping" "--echo" "--full" "--freeze" "--force-index-cleanup" "--jobs" "1" "--min-mxid-age" "min_mxid_age" "--min-xid-age" "min_xid_age" "--no-index-cleanup" "--no-process-main" "--no-process-toast" "--no-truncate" "--schema" "schema" "--exclude-schema" "exclude_schema" "--parallel" "1" "--quiet" "--skip-locked" "--table" "table" "--verbose" "--version" "--analyze" "--analyze-only" "--analyze-in-stages" "--help" "--host" "localhost" "--port" "5432" "--username" "username" "--no-password" "--password" "--maintenance-db" "maintenance_db""# + ), command.to_command_string() ); } diff --git a/postgresql_commands/src/vacuumlo.rs b/postgresql_commands/src/vacuumlo.rs index 0573fc5..e9305b1 100644 --- a/postgresql_commands/src/vacuumlo.rs +++ b/postgresql_commands/src/vacuumlo.rs @@ -230,7 +230,9 @@ mod tests { let command_prefix = r#"".\\vacuumlo" "#; assert_eq!( - format!(r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""#), + format!( + r#"{command_prefix}"--host" "localhost" "--port" "5432" "--username" "postgres""# + ), command.to_command_string() ); } @@ -257,7 +259,9 @@ mod tests { let command_prefix = String::new(); assert_eq!( - format!(r#"{command_prefix}"vacuumlo" "--limit" "100" "--dry-run" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""#), + format!( + r#"{command_prefix}"vacuumlo" "--limit" "100" "--dry-run" "--verbose" "--version" "--help" "--host" "localhost" "--port" "5432" "--username" "postgres" "--no-password" "--password""# + ), command.to_command_string() ); } diff --git a/postgresql_embedded/src/lib.rs b/postgresql_embedded/src/lib.rs index 49f0152..cc9742a 100644 --- a/postgresql_embedded/src/lib.rs +++ b/postgresql_embedded/src/lib.rs @@ -148,5 +148,5 @@ lazy_static::lazy_static! { pub static ref V12: VersionReq = VersionReq::parse("=12").unwrap(); } -pub use settings::BOOTSTRAP_SUPERUSER; pub use settings::BOOTSTRAP_DATABASE; +pub use settings::BOOTSTRAP_SUPERUSER; diff --git a/postgresql_embedded/tests/start_config.rs b/postgresql_embedded/tests/start_config.rs index 264dd30..0c3642a 100644 --- a/postgresql_embedded/tests/start_config.rs +++ b/postgresql_embedded/tests/start_config.rs @@ -1,6 +1,6 @@ -use postgresql_embedded::{BOOTSTRAP_DATABASE, PostgreSQL, Settings}; -use std::collections::HashMap; +use postgresql_embedded::{PostgreSQL, Settings, BOOTSTRAP_DATABASE}; use sqlx::{PgPool, Row}; +use std::collections::HashMap; use test_log::test; #[test(tokio::test)] From 588b624fc1b409a7898d0d50d1ef6892c4d412af Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 19:20:10 -0600 Subject: [PATCH 06/11] test: correct linux/macos tests --- postgresql_commands/src/createuser.rs | 2 +- postgresql_commands/src/ecpg.rs | 2 +- postgresql_commands/src/pg_ctl.rs | 2 +- postgresql_commands/src/pg_isready.rs | 2 +- postgresql_commands/src/pgbench.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/postgresql_commands/src/createuser.rs b/postgresql_commands/src/createuser.rs index 53a2923..e29ed04 100644 --- a/postgresql_commands/src/createuser.rs +++ b/postgresql_commands/src/createuser.rs @@ -505,7 +505,7 @@ mod tests { .pg_password("password") .build(); #[cfg(not(target_os = "windows"))] - let command_prefix = r#"PGPASSWORD="password" "#; + let command_prefix = r#"PGDATABASE="database" PGPASSWORD="password" "#; #[cfg(target_os = "windows")] let command_prefix = String::new(); diff --git a/postgresql_commands/src/ecpg.rs b/postgresql_commands/src/ecpg.rs index daa91e8..257bb19 100644 --- a/postgresql_commands/src/ecpg.rs +++ b/postgresql_commands/src/ecpg.rs @@ -231,7 +231,7 @@ mod tests { fn test_builder_from() { let command = EcpgBuilder::from(&TestSettings).build(); #[cfg(not(target_os = "windows"))] - let command_prefix = r#"PGPASSWORD="password" "./ecpg""#; + let command_prefix = r#""./ecpg""#; #[cfg(target_os = "windows")] let command_prefix = r#"".\\ecpg""#; diff --git a/postgresql_commands/src/pg_ctl.rs b/postgresql_commands/src/pg_ctl.rs index 5d2ec2f..c848efe 100644 --- a/postgresql_commands/src/pg_ctl.rs +++ b/postgresql_commands/src/pg_ctl.rs @@ -335,7 +335,7 @@ mod tests { fn test_builder_from() { let command = PgCtlBuilder::from(&TestSettings).build(); #[cfg(not(target_os = "windows"))] - let command_prefix = r#"./pg_ctl""#; + let command_prefix = r#""./pg_ctl""#; #[cfg(target_os = "windows")] let command_prefix = r#"".\\pg_ctl""#; diff --git a/postgresql_commands/src/pg_isready.rs b/postgresql_commands/src/pg_isready.rs index da2c27c..b10e580 100644 --- a/postgresql_commands/src/pg_isready.rs +++ b/postgresql_commands/src/pg_isready.rs @@ -187,7 +187,7 @@ mod tests { fn test_builder_from() { let command = PgIsReadyBuilder::from(&TestSettings).build(); #[cfg(not(target_os = "windows"))] - let command_prefix = r#"PGPASSWORD="password" "./pg_isready" "#; + let command_prefix = r#""./pg_isready" "#; #[cfg(target_os = "windows")] let command_prefix = r#"".\\pg_isready" "#; diff --git a/postgresql_commands/src/pgbench.rs b/postgresql_commands/src/pgbench.rs index 0e946b7..2428536 100644 --- a/postgresql_commands/src/pgbench.rs +++ b/postgresql_commands/src/pgbench.rs @@ -667,7 +667,7 @@ mod tests { fn test_builder_from() { let command = PgBenchBuilder::from(&TestSettings).build(); #[cfg(not(target_os = "windows"))] - let command_prefix = r#"./pgbench" "#; + let command_prefix = r#""./pgbench" "#; #[cfg(target_os = "windows")] let command_prefix = r#"".\\pgbench" "#; From e1e01c54822b9e17b7d04b295ab133145de59fd6 Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 19:32:09 -0600 Subject: [PATCH 07/11] test: increase timeout to 30 seconds --- postgresql_embedded/src/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgresql_embedded/src/settings.rs b/postgresql_embedded/src/settings.rs index d31c4d9..afc82d1 100644 --- a/postgresql_embedded/src/settings.rs +++ b/postgresql_embedded/src/settings.rs @@ -109,7 +109,7 @@ impl Settings { username: BOOTSTRAP_SUPERUSER.to_string(), password, temporary: true, - timeout: Some(Duration::from_secs(5)), + timeout: Some(Duration::from_secs(30)), configuration: HashMap::new(), } } From 3d51a8d928c7fe4d8b4bb66d9c7b831b2ca49cc2 Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 19:40:06 -0600 Subject: [PATCH 08/11] test: increase timeout to 30 seconds --- postgresql_embedded/src/settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgresql_embedded/src/settings.rs b/postgresql_embedded/src/settings.rs index afc82d1..3a6a42c 100644 --- a/postgresql_embedded/src/settings.rs +++ b/postgresql_embedded/src/settings.rs @@ -289,7 +289,7 @@ mod tests { .url("test") .replace(settings.password.as_str(), "password") ); - assert_eq!(Some(Duration::from_secs(5)), settings.timeout); + assert_eq!(Some(Duration::from_secs(30)), settings.timeout); assert!(settings.configuration.is_empty()); } From bf78e89748e5b32ee8becb18d76afd300c8edf6f Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 19:05:46 -0700 Subject: [PATCH 09/11] build: update non-windows build configuration --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daafaff..2db27e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,17 @@ jobs: tool: grcov - name: Tests + if: ${{ !startsWith(matrix.os, 'ubuntu-') }} + env: + CARGO_TERM_COLOR: always + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + RUST_LOG: "info,postgresql_archive=debug,postgresql_commands=debug,postgresql_embedded=debug" + RUST_LOG_SPAN_EVENTS: full + run: | + cargo test --workspace + + - name: Tests + if: ${{ startsWith(matrix.os, 'ubuntu-') }} env: CARGO_TERM_COLOR: always GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 63f5f08e8581354a891eedaef1a1a729a91a1666 Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 19:24:08 -0700 Subject: [PATCH 10/11] build: update non-windows build tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2db27e1..c692113 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: RUST_LOG: "info,postgresql_archive=debug,postgresql_commands=debug,postgresql_embedded=debug" RUST_LOG_SPAN_EVENTS: full run: | - cargo test --workspace + cargo test - name: Tests if: ${{ startsWith(matrix.os, 'ubuntu-') }} From 5e5aac07f3bea952bbfd5dccedbdead0d9b8cb40 Mon Sep 17 00:00:00 2001 From: brianheineman Date: Fri, 5 Jul 2024 19:34:47 -0700 Subject: [PATCH 11/11] test: revert timeout to 5 seconds --- postgresql_embedded/src/settings.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgresql_embedded/src/settings.rs b/postgresql_embedded/src/settings.rs index 3a6a42c..d31c4d9 100644 --- a/postgresql_embedded/src/settings.rs +++ b/postgresql_embedded/src/settings.rs @@ -109,7 +109,7 @@ impl Settings { username: BOOTSTRAP_SUPERUSER.to_string(), password, temporary: true, - timeout: Some(Duration::from_secs(30)), + timeout: Some(Duration::from_secs(5)), configuration: HashMap::new(), } } @@ -289,7 +289,7 @@ mod tests { .url("test") .replace(settings.password.as_str(), "password") ); - assert_eq!(Some(Duration::from_secs(30)), settings.timeout); + assert_eq!(Some(Duration::from_secs(5)), settings.timeout); assert!(settings.configuration.is_empty()); }