Skip to content

Commit

Permalink
tests: add automatic download integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
devmatteini committed Dec 3, 2023
1 parent 24aa023 commit 74bc6da
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ mod archives {
}
}

mod downloads {
use crate::fs::{any_temp_file, path_to_string};
mod download {
use crate::fs::{any_temp_dir, any_temp_file, path_to_string};
use assert_cmd::Command;

#[test]
Expand Down Expand Up @@ -111,4 +111,36 @@ mod downloads {
"No asset found for Source code (tar.gz)",
));
}

#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
#[test]
fn automatic_download() {
let temp_dir = any_temp_dir();

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

cmd.current_dir(&temp_dir)
.arg("download")
.arg("-a")
.arg("devmatteini/dra-tests")
.assert()
.success();

let expected_asset = if cfg!(target_os = "linux") {
"helloworld-x86_64-linux.tar.gz"
} else if cfg!(target_os = "windows") {
"helloworld-x86_64-windows.tar.gz"
} else if cfg!(target_os = "macos") {
"helloworld-x86_64-apple-darwin.tar.gz"
} else {
panic!("This test should only run on linux, macOS and windows")
};

assert!(
temp_dir.join(expected_asset).exists(),
"Expected asset '{}' not exists in {}",
expected_asset,
temp_dir.display()
);
}
}

0 comments on commit 74bc6da

Please sign in to comment.