Skip to content

Commit

Permalink
test(download): fix clippy warnings regarding Mutex in async
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Jun 4, 2024
1 parent 6d43761 commit d1cc5ca
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions download/tests/read-proxy-env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ use std::env::{remove_var, set_var};
use std::error::Error;
use std::net::TcpListener;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use std::thread;
use std::time::Duration;

use env_proxy::for_url;
use once_cell::sync::Lazy;
use reqwest::{Client, Proxy};
use tokio::sync::Mutex;
use url::Url;

static SERIALISE_TESTS: Mutex<()> = Mutex::new(());
static SERIALISE_TESTS: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));

fn scrub_env() {
remove_var("http_proxy");
Expand All @@ -29,9 +30,7 @@ fn scrub_env() {
// Tests for correctly retrieving the proxy (host, port) tuple from $https_proxy
#[tokio::test]
async fn read_basic_proxy_params() {
let _guard = SERIALISE_TESTS
.lock()
.expect("Unable to lock the test guard");
let _guard = SERIALISE_TESTS.lock().await;
scrub_env();
set_var("https_proxy", "http://proxy.example.com:8080");
let u = Url::parse("https://www.example.org").ok().unwrap();
Expand All @@ -45,9 +44,7 @@ async fn read_basic_proxy_params() {
#[tokio::test]
async fn socks_proxy_request() {
static CALL_COUNT: AtomicUsize = AtomicUsize::new(0);
let _guard = SERIALISE_TESTS
.lock()
.expect("Unable to lock the test guard");
let _guard = SERIALISE_TESTS.lock().await;

scrub_env();
set_var("all_proxy", "socks5://127.0.0.1:1080");
Expand Down

0 comments on commit d1cc5ca

Please sign in to comment.