Skip to content

Commit

Permalink
tests: reorder some install tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devmatteini committed Nov 16, 2024
1 parent c569995 commit 2f231b8
Showing 1 changed file with 96 additions and 96 deletions.
192 changes: 96 additions & 96 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,102 +12,6 @@ mod install {

use crate::assertions::assert_file_exists;

#[cfg(target_family = "unix")]
#[test_case("helloworld-many-executables-unix.tar.gz", "random-script", "helloworld-v2"; "install 2 executables")]
fn installed_multiple_successfully(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result
.success()
.stdout(predicates::str::contains("Installation completed"));

assert_file_exists(output_dir.join(exec1).as_path());
assert_file_exists(output_dir.join(exec2).as_path());
}

#[cfg(target_family = "unix")]
#[test_case("helloworld-many-executables-unix.tar.gz", "wrong-exec", "helloworld-v2"; "executable not found")]
fn installed_multiple_partial_failed(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result.failure().stderr(predicates::str::contains(format!(
"Executable {} not found",
exec1
)));

assert_file_exists(output_dir.join(exec2).as_path());
}

#[cfg(target_family = "windows")]
#[test_case("helloworld-many-executables-windows.zip", "wrong-exec.exe", "helloworld-v2.exe"; "executable not found")]
fn installed_multiple_partial_failed(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result.failure().stderr(predicates::str::contains(format!(
"Executable {} not found",
exec1
)));

assert_file_exists(output_dir.join(exec2).as_path());
}

#[cfg(target_family = "windows")]
#[test_case("helloworld-many-executables-windows.zip", "random-script.exe", "helloworld-v2.exe"; "install 2 executables")]
fn installed_multiple_successfully(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result
.success()
.stdout(predicates::str::contains("Installation completed"));

assert_file_exists(output_dir.join(exec1).as_path());
assert_file_exists(output_dir.join(exec2).as_path());
}

#[cfg(target_family = "unix")]
#[test_case("helloworld.tar.gz", "helloworld"; "tar gzip")]
#[test_case("helloworld.tgz", "helloworld"; "tar tgz")]
Expand Down Expand Up @@ -231,6 +135,102 @@ mod install {
.stdout(predicates::str::contains("Installation completed"));
assert_file_exists(&expected_installed_file);
}

#[cfg(target_family = "unix")]
#[test_case("helloworld-many-executables-unix.tar.gz", "random-script", "helloworld-v2"; "install 2 executables")]
fn installed_multiple_successfully(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result
.success()
.stdout(predicates::str::contains("Installation completed"));

assert_file_exists(output_dir.join(exec1).as_path());
assert_file_exists(output_dir.join(exec2).as_path());
}

#[cfg(target_family = "windows")]
#[test_case("helloworld-many-executables-windows.zip", "random-script.exe", "helloworld-v2.exe"; "install 2 executables")]
fn installed_multiple_successfully(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result
.success()
.stdout(predicates::str::contains("Installation completed"));

assert_file_exists(output_dir.join(exec1).as_path());
assert_file_exists(output_dir.join(exec2).as_path());
}

#[cfg(target_family = "unix")]
#[test_case("helloworld-many-executables-unix.tar.gz", "wrong-exec", "helloworld-v2"; "executable not found")]
fn installed_multiple_partial_failed(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result.failure().stderr(predicates::str::contains(format!(
"Executable {} not found",
exec1
)));

assert_file_exists(output_dir.join(exec2).as_path());
}

#[cfg(target_family = "windows")]
#[test_case("helloworld-many-executables-windows.zip", "wrong-exec.exe", "helloworld-v2.exe"; "executable not found")]
fn installed_multiple_partial_failed(selected_asset: &str, exec1: &str, exec2: &str) {
let output_dir = any_temp_dir();

let mut cmd = Command::cargo_bin("dra").unwrap();

let result = cmd
.arg("download")
.args(["-s", selected_asset])
.args(["-o", &path_to_string(output_dir.clone())])
.args(["-I", exec1])
.args(["-I", exec2])
.arg("devmatteini/dra-tests")
.assert();

result.failure().stderr(predicates::str::contains(format!(
"Executable {} not found",
exec1
)));

assert_file_exists(output_dir.join(exec2).as_path());
}
}

mod download {
Expand Down

0 comments on commit 2f231b8

Please sign in to comment.