Skip to content

Commit

Permalink
Start using serial_test for test serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtcollins committed Jan 28, 2024
1 parent caac61b commit a1ca230
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
72 changes: 72 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ opentelemetry-otlp = "0.14.0"
opentelemetry_sdk = { version = "0.21.0", features = ["rt-tokio"] }
proptest = "1.1.0"
rustup-macros = { path = "rustup-macros" }
serial_test = "3"
tempfile = "3.8"
termcolor = "1.2"
thiserror = "1.0"
Expand Down
1 change: 1 addition & 0 deletions download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ hyper = { version = "1.0", default-features = false, features = [
"server",
] }
hyper-util = { version = "0.1.1", features = ["tokio"] }
serial_test.workspace = true
tempfile.workspace = true
13 changes: 3 additions & 10 deletions download/tests/read-proxy-env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ 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 reqwest::{Client, Proxy};
use serial_test::serial;
use url::Url;

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

fn scrub_env() {
remove_var("http_proxy");
remove_var("https_proxy");
Expand All @@ -28,10 +26,8 @@ fn scrub_env() {

// Tests for correctly retrieving the proxy (host, port) tuple from $https_proxy
#[tokio::test]
#[serial]
async fn read_basic_proxy_params() {
let _guard = SERIALISE_TESTS
.lock()
.expect("Unable to lock the test guard");
scrub_env();
set_var("https_proxy", "http://proxy.example.com:8080");
let u = Url::parse("https://www.example.org").ok().unwrap();
Expand All @@ -43,12 +39,9 @@ async fn read_basic_proxy_params() {

// Tests to verify if socks feature is available and being used
#[tokio::test]
#[serial]
async fn socks_proxy_request() {
static CALL_COUNT: AtomicUsize = AtomicUsize::new(0);
let _guard = SERIALISE_TESTS
.lock()
.expect("Unable to lock the test guard");

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

Expand Down

0 comments on commit a1ca230

Please sign in to comment.