From 1e849939b9f92fc04c2343cc5770d1f55ab71f66 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 1 Jul 2026 21:39:45 +0900 Subject: test(repository-manager): port testFilterRepoWrapping PathRepository already implements RepositoryInterface and create_repository already handles the "path" class, so the prior ignore reason no longer applies; verify the FilterRepository/PathRepository wrapping via RepositoryInterfaceHandle::is/downcast_rc. --- .../tests/repository/repository_manager_test.rs | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/shirabe/tests/repository/repository_manager_test.rs b/crates/shirabe/tests/repository/repository_manager_test.rs index 089ce9a..c67cec4 100644 --- a/crates/shirabe/tests/repository/repository_manager_test.rs +++ b/crates/shirabe/tests/repository/repository_manager_test.rs @@ -8,7 +8,9 @@ use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; -use shirabe::repository::{ArrayRepository, RepositoryInterfaceHandle, RepositoryManager}; +use shirabe::repository::{ + ArrayRepository, FilterRepository, PathRepository, RepositoryInterfaceHandle, RepositoryManager, +}; use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloader; use shirabe_php_shim::PhpMixed; @@ -210,9 +212,34 @@ fn test_invalid_repo_creation_throws() { } #[test] -#[ignore = "PathRepository does not implement RepositoryInterface (only ConfigurableRepositoryInterface), so it cannot live inside a RepositoryInterfaceHandle nor be recovered via as_any().downcast_ref::(); the assertInstanceOf(PathRepository) check is unportable"] fn test_filter_repo_wrapping() { let SetUp { tmpdir } = set_up(); let _tear_down = TearDown::new(tmpdir.path().to_path_buf()); - todo!() + + let io = null_io(); + let config = Rc::new(RefCell::new(Config::new(false, None))); + let mut rm = RepositoryManager::new(io.clone(), config, http_downloader(&io), None, None); + + rm.set_repository_class("path", "Composer\\Repository\\PathRepository"); + let repo = rm + .create_repository( + "path", + str_config(&[ + ("type", PhpMixed::String("path".to_string())), + ( + "url", + PhpMixed::String(format!("{}/tests/repository", env!("CARGO_MANIFEST_DIR"))), + ), + ( + "only", + PhpMixed::List(vec![PhpMixed::String("foo/bar".to_string())]), + ), + ]), + None, + ) + .unwrap(); + + assert!(repo.is::()); + let filter = repo.downcast_rc::().unwrap(); + assert!(filter.borrow().get_repository().is::()); } -- cgit v1.3.1