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 /crates/shirabe/tests/package | |
| 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>
Diffstat (limited to 'crates/shirabe/tests/package')
| -rw-r--r-- | crates/shirabe/tests/package/main.rs | 1 | ||||
| -rw-r--r-- | crates/shirabe/tests/package/root_alias_package_test.rs | 72 |
2 files changed, 73 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()); +} |
