Skip to content

Commit

Permalink
use a temp BUCKLE_CACHE in tests
Browse files Browse the repository at this point in the history
this stops tests taking the happy path where the user alrady has buck2 downloaded

tested with: cargo test
  • Loading branch information
ahornby committed Jul 22, 2023
1 parent 80955d0 commit c038b01
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/integration_buck2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use assert_cmd::Command;
/// Integration test that buckle can download buck2 and run it with same arguments.
#[test]
fn test_buck2_latest() {
let tmpdir = tempfile::TempDir::new().unwrap();
let mut cmd = Command::cargo_bin("buckle").unwrap();
cmd.env("BUCKLE_CACHE", tmpdir.path().as_os_str());
cmd.arg("--version");
let assert = cmd.assert();
let stdout = String::from_utf8(assert.get_output().stdout.to_vec()).unwrap();
Expand All @@ -16,7 +18,9 @@ fn test_buck2_latest() {
/// version
#[test]
fn test_buck2_specific_version() {
let tmpdir = tempfile::TempDir::new().unwrap();
let mut cmd = Command::cargo_bin("buckle").unwrap();
cmd.env("BUCKLE_CACHE", tmpdir.path().as_os_str());
cmd.env("USE_BUCK2_VERSION", "2023-07-15");
cmd.arg("--version");
// TODO verify the right version is download after buck2 properly states it's version
Expand All @@ -28,7 +32,9 @@ fn test_buck2_specific_version() {

#[test]
fn test_buck2_fail() {
let tmpdir = tempfile::TempDir::new().unwrap();
let mut cmd = Command::cargo_bin("buckle").unwrap();
cmd.env("BUCKLE_CACHE", tmpdir.path().as_os_str());
cmd.arg("--totally-unknown-argument");
let assert = cmd.assert();
let stderr = String::from_utf8(assert.get_output().stderr.to_vec()).unwrap();
Expand Down

0 comments on commit c038b01

Please sign in to comment.