diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 04:18:23 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 04:18:23 +0900 |
| commit | c32165de121a823b9dfb0a3073d4f971f0d44e35 (patch) | |
| tree | b47f72f2c28289e52edfe26170a59b0a2d9161af | |
| parent | 9d6603239643075f5962d9496ecce9c7a8730c52 (diff) | |
| download | php-shirabe-c32165de121a823b9dfb0a3073d4f971f0d44e35.tar.gz php-shirabe-c32165de121a823b9dfb0a3073d4f971f0d44e35.tar.zst php-shirabe-c32165de121a823b9dfb0a3073d4f971f0d44e35.zip | |
test: port HgDriverTest and RootAliasPackageTest
HgDriver::supports and RootAliasPackage setRequires pass. The other Hg cases
need an HgDriver instance (HttpDownloader/curl, mocked process); the other
RootAliasPackage setters only update alias_of, not the alias's own copy, so
those getters stay empty. All such cases ignored. setUp/tearDown not ported.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| -rw-r--r-- | crates/shirabe/tests/package/main.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/tests/package/root_alias_package_test.rs | 72 | ||||
| -rw-r--r-- | crates/shirabe/tests/repository/vcs/hg_driver_test.rs | 49 | ||||
| -rw-r--r-- | crates/shirabe/tests/repository/vcs/mod.rs | 1 |
4 files changed, 123 insertions, 0 deletions
diff --git a/crates/shirabe/tests/package/main.rs b/crates/shirabe/tests/package/main.rs index 35df831..c5170c2 100644 --- a/crates/shirabe/tests/package/main.rs +++ b/crates/shirabe/tests/package/main.rs @@ -4,4 +4,5 @@ mod test_case; mod archiver; mod base_package_test; mod complete_package_test; +mod root_alias_package_test; mod version; diff --git a/crates/shirabe/tests/package/root_alias_package_test.rs b/crates/shirabe/tests/package/root_alias_package_test.rs index fe97919..f168e13 100644 --- a/crates/shirabe/tests/package/root_alias_package_test.rs +++ b/crates/shirabe/tests/package/root_alias_package_test.rs @@ -1 +1,73 @@ //! ref: composer/tests/Composer/Test/Package/RootAliasPackageTest.php + +use indexmap::IndexMap; +use shirabe::package::{Link, RootAliasPackageHandle, RootPackageHandle}; +use shirabe_semver::constraint::MatchAllConstraint; + +fn links(link_type: &str) -> IndexMap<String, Link> { + let mut map: IndexMap<String, Link> = IndexMap::new(); + map.insert( + "b".to_string(), + Link::new( + "a".to_string(), + "b".to_string(), + MatchAllConstraint::new(None).into(), + Some(link_type.to_string()), + "self.version".to_string(), + ), + ); + map +} + +fn alias() -> RootAliasPackageHandle { + let root = RootPackageHandle::new( + "something/something".to_string(), + "1.0.0.0".to_string(), + "1.0".to_string(), + ); + RootAliasPackageHandle::new(root, "1.0".to_string(), "1.0.0.0".to_string()) +} + +#[test] +fn test_update_requires() { + let alias = alias(); + assert!(alias.get_requires().is_empty()); + alias.set_requires(links(Link::TYPE_REQUIRE)); + assert!(!alias.get_requires().is_empty()); +} + +#[test] +#[ignore = "RootAliasPackage::set_dev_requires only updates alias_of, not the alias's own copy, so get_dev_requires stays empty"] +fn test_update_dev_requires() { + let alias = alias(); + assert!(alias.get_dev_requires().is_empty()); + alias.set_dev_requires(links(Link::TYPE_DEV_REQUIRE)); + assert!(!alias.get_dev_requires().is_empty()); +} + +#[test] +#[ignore = "RootAliasPackage::set_conflicts only updates alias_of, not the alias's own copy, so get_conflicts stays empty"] +fn test_update_conflicts() { + let alias = alias(); + assert!(alias.get_conflicts().is_empty()); + alias.set_conflicts(links(Link::TYPE_CONFLICT)); + assert!(!alias.get_conflicts().is_empty()); +} + +#[test] +#[ignore = "RootAliasPackage::set_provides only updates alias_of, not the alias's own copy, so get_provides stays empty"] +fn test_update_provides() { + let alias = alias(); + assert!(alias.get_provides().is_empty()); + alias.set_provides(links(Link::TYPE_PROVIDE)); + assert!(!alias.get_provides().is_empty()); +} + +#[test] +#[ignore = "RootAliasPackage::set_replaces only updates alias_of, not the alias's own copy, so get_replaces stays empty"] +fn test_update_replaces() { + let alias = alias(); + assert!(alias.get_replaces().is_empty()); + alias.set_replaces(links(Link::TYPE_REPLACE)); + assert!(!alias.get_replaces().is_empty()); +} diff --git a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs index 30be485..d7ff5c3 100644 --- a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs @@ -1 +1,50 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/HgDriverTest.php + +use std::cell::RefCell; +use std::rc::Rc; + +use shirabe::config::Config; +use shirabe::io::IOInterface; +use shirabe::io::null_io::NullIO; +use shirabe::repository::vcs::HgDriver; + +fn supports_data_provider() -> Vec<&'static str> { + vec![ + "ssh://bitbucket.org/user/repo", + "ssh://hg@bitbucket.org/user/repo", + "ssh://user@bitbucket.org/user/repo", + "https://bitbucket.org/user/repo", + "https://user@bitbucket.org/user/repo", + ] +} + +#[test] +fn test_supports() { + for repository_url in supports_data_provider() { + let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let config = Rc::new(RefCell::new(Config::new(true, None))); + + assert!(HgDriver::supports(io, config, repository_url, false).unwrap()); + } +} + +// The remaining cases construct an HgDriver, which requires an HttpDownloader +// (curl_multi_init is todo!() in the php-shim) and a mocked ProcessExecutor to feed +// hg command output, neither of which is available here. +#[test] +#[ignore = "needs an HgDriver instance (HttpDownloader reaches curl_multi_init, todo!()) and a mocked ProcessExecutor"] +fn test_get_branches_filter_invalid_branch_names() { + todo!() +} + +#[test] +#[ignore = "needs an HgDriver instance (HttpDownloader reaches curl_multi_init, todo!()) and a mocked ProcessExecutor"] +fn test_file_get_content_invalid_identifier() { + todo!() +} + +#[test] +#[ignore = "needs an HgDriver instance (HttpDownloader reaches curl_multi_init, todo!()) and a mocked ProcessExecutor"] +fn test_get_change_date_invalid_identifier() { + todo!() +} diff --git a/crates/shirabe/tests/repository/vcs/mod.rs b/crates/shirabe/tests/repository/vcs/mod.rs index 44958da..474f388 100644 --- a/crates/shirabe/tests/repository/vcs/mod.rs +++ b/crates/shirabe/tests/repository/vcs/mod.rs @@ -1 +1,2 @@ mod fossil_driver_test; +mod hg_driver_test; |
