From 4c1fbdbd648cc1f65183f51e1143b538b83fe8ff Mon Sep 17 00:00:00 2001 From: "Andrew Phillips (aider)" Date: Mon, 12 May 2025 11:25:32 -0300 Subject: [PATCH] fix: improve command execution in tests --- src/tests.rs | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 44e8cf9..2719ecf 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -53,10 +53,11 @@ mod tests { // Save an item with some content let input = "test content"; + // Create a command that pipes input to keep with the specified environment + let cmd = format!("echo {} | {}", input, env); let mut child = Command::new("sh") .arg("-c") - .arg(format!("echo {} | {}", input, env)) - .arg("cargo run -- --save")) + .arg(cmd) .spawn() .expect("Failed to spawn process"); @@ -83,10 +84,11 @@ mod tests { // Save an item with some content let input = "test content"; + // Create a command that pipes input to keep with the specified environment + let cmd = format!("echo {} | {}", input, env); let mut child = Command::new("sh") .arg("-c") - .arg(format!("echo {} | {}", input, env)) - .arg("cargo run -- --save")) + .arg(cmd) .spawn() .expect("Failed to spawn process"); @@ -112,10 +114,11 @@ mod tests { // Save an item with some content let input = "test content"; + // Create a command that pipes input to keep with the specified environment + let cmd = format!("echo {} | {}", input, env); let mut child = Command::new("sh") .arg("-c") - .arg(format!("echo {} | {}", input, env)) - .arg("cargo run -- --save")) + .arg(cmd) .spawn() .expect("Failed to spawn process"); @@ -141,10 +144,11 @@ mod tests { // Save an item with some content let input = "test content"; + // Create a command that pipes input to keep with the specified environment + let cmd = format!("echo {} | {}", input, env); let mut child = Command::new("sh") .arg("-c") - .arg(format!("echo {} | {}", input, env)) - .arg("cargo run -- --save")) + .arg(cmd) .spawn() .expect("Failed to spawn process"); @@ -186,10 +190,12 @@ mod tests { // Save an item with some content and metadata let input = "test content"; + // Create a command that pipes input to keep with the specified environment and metadata + let cmd = format!("echo {} | {}", input, env); let mut child = Command::new("sh") .arg("-c") - .arg(format!("echo {} | {}", input, env)) - .arg("cargo run -- --save --meta key=value")) + .arg(cmd) + .arg("cargo run -- --save --meta key=value") .spawn() .expect("Failed to spawn process"); @@ -224,10 +230,12 @@ mod tests { // Save an item with some content and tags let input = "test content"; + // Create a command that pipes input to keep with the specified environment and tags + let cmd = format!("echo {} | {}", input, env); let mut child = Command::new("sh") .arg("-c") - .arg(format!("echo {} | {}", input, env)) - .arg("cargo run -- --save --tag tag1 --tag tag2")) + .arg(cmd) + .arg("cargo run -- --save --tag tag1 --tag tag2") .spawn() .expect("Failed to spawn process"); @@ -253,10 +261,12 @@ mod tests { // Save an item with some content and compression let input = "test content"; + // Create a command that pipes input to keep with the specified environment and compression + let cmd = format!("echo {} | {}", input, env); let mut child = Command::new("sh") .arg("-c") - .arg(format!("echo {} | {}", input, env)) - .arg("cargo run -- --save --compression gzip")) + .arg(cmd) + .arg("cargo run -- --save --compression gzip") .spawn() .expect("Failed to spawn process");