From 5feeb8a15c72f1095bc7ee0a9738dd8f66122231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Wed, 23 Oct 2024 09:28:25 -0700 Subject: [PATCH] Mark environment variable tests serial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- Cargo.lock | 78 ++++++++++++++++++++++++++++++++ axoupdater/Cargo.toml | 1 + axoupdater/src/release/github.rs | 6 +++ 3 files changed, 85 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 408c11d..96ea024 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -374,6 +374,7 @@ dependencies = [ "miette", "self-replace", "serde", + "serial_test", "tempfile", "thiserror", "tokio", @@ -893,6 +894,21 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.30" @@ -900,6 +916,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -908,6 +925,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.31" @@ -938,6 +966,12 @@ dependencies = [ "syn 2.0.82", ] +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + [[package]] name = "futures-task" version = "0.3.30" @@ -950,9 +984,13 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ + "futures-channel", "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -2042,6 +2080,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scc" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c1f7fc6deb21665a9060dfc7d271be784669295a31babdcd4dd2c79ae8cbfb" +dependencies = [ + "sdd", +] + [[package]] name = "schannel" version = "0.1.23" @@ -2081,6 +2128,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sdd" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" + [[package]] name = "security-framework" version = "2.10.0" @@ -2185,6 +2238,31 @@ dependencies = [ "serde", ] +[[package]] +name = "serial_test" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.82", +] + [[package]] name = "sha1" version = "0.10.6" diff --git a/axoupdater/Cargo.toml b/axoupdater/Cargo.toml index 3234f7b..3f8b6d2 100644 --- a/axoupdater/Cargo.toml +++ b/axoupdater/Cargo.toml @@ -42,3 +42,4 @@ self-replace = "1.5.0" [dev-dependencies] tokio = { version = "1.36.0", features = ["test-util"] } httpmock = "0.7.0" +serial_test = "3.1.1" diff --git a/axoupdater/src/release/github.rs b/axoupdater/src/release/github.rs index c4d4941..a5db383 100644 --- a/axoupdater/src/release/github.rs +++ b/axoupdater/src/release/github.rs @@ -286,6 +286,7 @@ mod test { use axoasset::reqwest::StatusCode; use axoasset::serde_json::json; use httpmock::prelude::*; + use serial_test::serial; use std::env; #[test] @@ -321,6 +322,7 @@ mod test { } #[test] + #[serial] // modifying the global state environment variables fn test_github_api_no_env_var() { env::remove_var("INSTALLER_DOWNLOAD_URL"); let result = github_api(); @@ -329,6 +331,7 @@ mod test { } #[test] + #[serial] // modifying the global state environment variables fn test_github_api_overwrite() { env::set_var("INSTALLER_DOWNLOAD_URL", "https://magic.com"); let result = github_api(); @@ -337,6 +340,7 @@ mod test { } #[tokio::test] + #[serial] // modifying the global state environment variables async fn test_get_latest_github_release_custom_endpoint() { let server = MockServer::start_async().await; env::set_var("INSTALLER_DOWNLOAD_URL", server.base_url()); @@ -373,6 +377,7 @@ mod test { } #[tokio::test] + #[serial] // modifying the global state environment variables async fn test_get_specific_github_tag_custom_endpoint() { let server = MockServer::start_async().await; env::set_var("INSTALLER_DOWNLOAD_URL", server.base_url()); @@ -395,6 +400,7 @@ mod test { } #[tokio::test] + #[serial] // modifying the global state environment variables async fn test_get_github_releases_custom_endpoint() { let server = MockServer::start_async().await; env::set_var("INSTALLER_DOWNLOAD_URL", server.base_url());