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/filesystem_repository.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/repository/filesystem_repository.rs') diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index 0dae316..14365f2 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -14,7 +14,7 @@ use shirabe_php_shim::{ use crate::config::is_php_integer_key; use crate::installed_versions::InstalledVersions; -use crate::installer::InstallationManager; +use crate::installer::InstallationManagerInterface; use crate::json::JsonFile; use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; @@ -209,7 +209,7 @@ impl FilesystemRepository { pub fn write( &mut self, dev_mode: bool, - installation_manager: &mut InstallationManager, + installation_manager: &mut dyn InstallationManagerInterface, ) -> Result<()> { let mut data: IndexMap = IndexMap::new(); data.insert("packages".to_string(), PhpMixed::List(vec![])); @@ -239,11 +239,7 @@ impl FilesystemRepository { if let Some(path_str) = &path && !path_str.is_empty() { - let normalized_path = self.filesystem.borrow_mut().normalize_path(&if self - .filesystem - .borrow() - .is_absolute_path(path_str) - { + let path_to_normalize = if self.filesystem.borrow().is_absolute_path(path_str) { path_str.clone() } else { format!( @@ -251,7 +247,11 @@ impl FilesystemRepository { Platform::get_cwd(false).unwrap_or_default(), path_str ) - }); + }; + let normalized_path = self + .filesystem + .borrow_mut() + .normalize_path(&path_to_normalize); install_path = Some(self.filesystem.borrow_mut().find_shortest_path( &repo_dir, &normalized_path, @@ -453,7 +453,7 @@ impl FilesystemRepository { /// @param array $installPaths fn generate_installed_versions( &mut self, - installation_manager: &InstallationManager, + installation_manager: &dyn InstallationManagerInterface, install_paths: &IndexMap>, dev_mode: bool, repo_dir: &str, -- cgit v1.3.1