Skip to content

Commit

Permalink
refactor(test/e2e): Refactor e2e.rs module to use gen_random_dir_name…
Browse files Browse the repository at this point in the history
… function for generating random directory names
  • Loading branch information
georgegiosue committed Apr 17, 2024
1 parent bb0d021 commit 9d429e0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,7 @@ mod utils {
.join("android")
.join(build_runtime.to_string());

let timestamp = std::time::SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Error to get current timestamp")
.as_millis()
.to_string();

let random: u32 = rand::thread_rng().gen();

let dir_name = format!("{}_{}_{}", "test", timestamp, random.to_string());
let dir_name = gen_random_dir_name("test");

let temp_dir = env::temp_dir().join(dir_name);

Expand All @@ -120,4 +112,18 @@ mod utils {
fs::remove_dir_all(android_project_path.parent().unwrap())
.expect("Error clean project dir from temp directory");
}

pub fn gen_random_dir_name(prefix: &str) -> String {
let timestamp = std::time::SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Error to get current timestamp")
.as_millis()
.to_string();

let random: u32 = rand::thread_rng().gen();

let dir_name = format!("{}_{}_{}", prefix, timestamp, random.to_string());

dir_name
}
}

0 comments on commit 9d429e0

Please sign in to comment.