Skip to content

Commit

Permalink
test: mark env::set_var unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
beeb committed Aug 5, 2024
1 parent 8bbd8bf commit d266ea1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 21 deletions.
16 changes: 13 additions & 3 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ mod tests {

// Request a new server from the pool
let mut server = mockito::Server::new_async().await;
env::set_var("base_url", format!("http://{}", server.host_with_port()));
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", format!("http://{}", server.host_with_port()));
}

// Create a mock
let _ = server
Expand Down Expand Up @@ -161,7 +164,10 @@ mod tests {
#[serial]
async fn login_401() {
let mut server = mockito::Server::new_async().await;
env::set_var("base_url", format!("http://{}", server.host_with_port()));
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", format!("http://{}", server.host_with_port()));
}

let data = r#"
{
Expand Down Expand Up @@ -189,7 +195,11 @@ mod tests {
#[serial]
async fn login_500() {
let mut server = mockito::Server::new_async().await;
env::set_var("base_url", format!("http://{}", server.host_with_port()));

unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", format!("http://{}", server.host_with_port()));
}

let data = r#"
{
Expand Down
5 changes: 4 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,10 @@ remappings_regenerate = true
"#;

let target_config = define_config(true);
env::set_var("config_file", target_config.to_string_lossy().to_string());
unsafe {
// became unsafe in Rust 1.80
env::set_var("config_file", target_config.to_string_lossy().to_string());
}

write_to_config(&target_config, content);

Expand Down
73 changes: 56 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ pub async fn run(command: Subcommands) -> Result<(), SoldeerError> {
let skip_warnings = push.skip_warnings;

// Check for sensitive files or directories
if !dry_run &&
!skip_warnings &&
check_dotfiles_recursive(&path) &&
!prompt_user_for_confirmation()
if !dry_run
&& !skip_warnings
&& check_dotfiles_recursive(&path)
&& !prompt_user_for_confirmation()
{
println!("{}", "Push operation aborted by the user.".yellow());
return Ok(());
Expand Down Expand Up @@ -344,7 +344,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: None,
Expand Down Expand Up @@ -392,7 +395,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: None,
Expand Down Expand Up @@ -438,7 +444,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Update(Update { regenerate_remappings: false });

Expand Down Expand Up @@ -481,7 +490,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Update(Update { regenerate_remappings: false });

Expand Down Expand Up @@ -536,7 +548,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: None,
Expand Down Expand Up @@ -722,7 +737,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: Some("forge-std~1.9.1".to_string()),
Expand Down Expand Up @@ -774,7 +792,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: Some("forge-std~1.9.1".to_string()),
Expand Down Expand Up @@ -826,7 +847,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: Some("forge-std~1.9.1".to_string()),
Expand Down Expand Up @@ -878,7 +902,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: Some("forge-std~1.9.1".to_string()),
Expand Down Expand Up @@ -930,7 +957,10 @@ libs = ["dependencies"]

write_to_config(&target_config, content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Install(Install {
dependency: Some("forge-std~1.9.1".to_string()),
Expand Down Expand Up @@ -966,7 +996,10 @@ libs = ["dependencies"]
let content = String::new();
write_to_config(&target_config, &content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Init(Init { clean: false });

Expand Down Expand Up @@ -1015,7 +1048,10 @@ libs = ["dependencies"]
let content = String::new();
write_to_config(&target_config, &content);

env::set_var("base_url", "https://api.soldeer.xyz");
unsafe {
// became unsafe in Rust 1.80
env::set_var("base_url", "https://api.soldeer.xyz");
}

let command = Subcommands::Init(Init { clean: true });

Expand Down Expand Up @@ -1068,7 +1104,10 @@ libs = ["dependencies"]
}

let path = env::current_dir().unwrap().join("test").join(target);
env::set_var("config_file", path.to_string_lossy().to_string());
unsafe {
// became unsafe in Rust 1.80
env::set_var("config_file", path.to_string_lossy().to_string());
}
path
}

Expand Down

0 comments on commit d266ea1

Please sign in to comment.