Skip to content

Commit d1cc5ca

Browse files
committed
test(download): fix clippy warnings regarding Mutex in async
1 parent 6d43761 commit d1cc5ca

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

download/tests/read-proxy-env.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ use std::env::{remove_var, set_var};
44
use std::error::Error;
55
use std::net::TcpListener;
66
use std::sync::atomic::{AtomicUsize, Ordering};
7-
use std::sync::Mutex;
87
use std::thread;
98
use std::time::Duration;
109

1110
use env_proxy::for_url;
11+
use once_cell::sync::Lazy;
1212
use reqwest::{Client, Proxy};
13+
use tokio::sync::Mutex;
1314
use url::Url;
1415

15-
static SERIALISE_TESTS: Mutex<()> = Mutex::new(());
16+
static SERIALISE_TESTS: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
1617

1718
fn scrub_env() {
1819
remove_var("http_proxy");
@@ -29,9 +30,7 @@ fn scrub_env() {
2930
// Tests for correctly retrieving the proxy (host, port) tuple from $https_proxy
3031
#[tokio::test]
3132
async fn read_basic_proxy_params() {
32-
let _guard = SERIALISE_TESTS
33-
.lock()
34-
.expect("Unable to lock the test guard");
33+
let _guard = SERIALISE_TESTS.lock().await;
3534
scrub_env();
3635
set_var("https_proxy", "http://proxy.example.com:8080");
3736
let u = Url::parse("https://www.example.org").ok().unwrap();
@@ -45,9 +44,7 @@ async fn read_basic_proxy_params() {
4544
#[tokio::test]
4645
async fn socks_proxy_request() {
4746
static CALL_COUNT: AtomicUsize = AtomicUsize::new(0);
48-
let _guard = SERIALISE_TESTS
49-
.lock()
50-
.expect("Unable to lock the test guard");
47+
let _guard = SERIALISE_TESTS.lock().await;
5148

5249
scrub_env();
5350
set_var("all_proxy", "socks5://127.0.0.1:1080");

0 commit comments

Comments
 (0)