From 340164c64e90d44b1bdf620b514166db1f76cc98 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 24 Jun 2026 00:47:20 +0900 Subject: test: port more unimplemented tests Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/util/http/proxy_manager.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates/shirabe/src/util/http') diff --git a/crates/shirabe/src/util/http/proxy_manager.rs b/crates/shirabe/src/util/http/proxy_manager.rs index 37d73c0..d0ff9d9 100644 --- a/crates/shirabe/src/util/http/proxy_manager.rs +++ b/crates/shirabe/src/util/http/proxy_manager.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/Http/ProxyManager.php +use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Mutex, OnceLock}; use crate::downloader::TransportException; @@ -9,12 +10,17 @@ use crate::util::http::RequestProxy; static INSTANCE: OnceLock>> = OnceLock::new(); +// Distinguishes ProxyManager instances so tests can mirror PHP `===` identity of the singleton, +// which the Rust value-based singleton does not otherwise expose. +static NEXT_GENERATION: AtomicU64 = AtomicU64::new(0); + #[derive(Debug)] pub struct ProxyManager { error: Option, http_proxy: Option, https_proxy: Option, no_proxy_handler: std::cell::RefCell>, + generation: u64, } impl ProxyManager { @@ -24,6 +30,7 @@ impl ProxyManager { http_proxy: None, https_proxy: None, no_proxy_handler: std::cell::RefCell::new(None), + generation: NEXT_GENERATION.fetch_add(1, Ordering::Relaxed), }; if let Err(e) = instance.get_proxy_data() { instance.error = Some(e.to_string()); @@ -41,6 +48,12 @@ impl ProxyManager { } } + /// For testing only: a unique id per constructed instance, used to mirror PHP `===` identity + /// comparison of the ProxyManager singleton across `get_instance`/`reset`. + pub fn __generation(&self) -> u64 { + self.generation + } + pub fn has_proxy(&self) -> bool { self.http_proxy.is_some() || self.https_proxy.is_some() } -- cgit v1.3.1