From e98823e599eb375b30037cc714710e3309d927d1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 27 Jun 2026 17:21:00 +0900 Subject: test: port Composer tests unblocked by mockall, add seams Port 11 categories of previously-ignored Composer tests now reachable with the mockall crate: DownloadManager, VCS/Perforce/File downloaders, VersionSelector, PlatformRepository, Auditor, installer/FilesystemRepository, RootPackageLoader, util auth/http, commands, and Cache. Extract test seams additively on concrete structs as *Interface traits (Runtime, HhvmDetector, VersionGuesser, RepositorySet, Perforce, BinaryInstaller) plus mock-field seams (Cache, Filesystem); consumers take trait objects. Mocks are defined locally in the test crates via mockall::mock!, since automock-generated mocks are cfg(test)-gated and invisible across the integration-test boundary. dataProviders are ported in full; tests blocked by unported shims stay #[ignore] with documented reasons rather than reduced or weakened. Fix product bugs surfaced by the ports: - util/github: use the exception code, not the HTTP status, for 401/403 - advisory: serialize empty audit maps as [] to match PHP json_encode - repository/filesystem and downloader/file: fix RefCell double-borrow panics Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/repository/vcs/perforce_driver.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'crates/shirabe/src/repository/vcs/perforce_driver.rs') diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs index 50d5eb9..cb280e5 100644 --- a/crates/shirabe/src/repository/vcs/perforce_driver.rs +++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs @@ -9,6 +9,7 @@ use crate::config::Config; use crate::io::IOInterface; use crate::repository::vcs::VcsDriverBase; use crate::util::Perforce; +use crate::util::PerforceInterface; use crate::util::ProcessExecutor; use crate::util::http::Response; @@ -17,7 +18,7 @@ pub struct PerforceDriver { inner: VcsDriverBase, pub(crate) depot: String, pub(crate) branch: String, - pub(crate) perforce: Option, + pub(crate) perforce: Option>, } impl PerforceDriver { @@ -86,17 +87,23 @@ impl PerforceDriver { } let repo_dir = format!("{}/{}", cache_vcs_dir, self.depot); - self.perforce = Some(Perforce::create( + self.perforce = Some(Box::new(Perforce::create( repo_config.clone(), self.inner.url.clone(), repo_dir, self.inner.process.clone(), self.inner.io.clone(), - )); + ))); Ok(()) } + /// For testing only. Rust equivalent of the reflection-based + /// `overrideDriverInternalPerforce` helper in PerforceDriverTest. + pub fn __override_perforce(&mut self, perforce: Box) { + self.perforce = Some(perforce); + } + pub fn get_file_content( &mut self, file: &str, -- cgit v1.3.1