diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 01:19:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 01:47:58 +0900 |
| commit | b5a9d37a7880b05cb3ba1fdbe5b8873295621514 (patch) | |
| tree | fa16db033aa869f0aa4517ba5e9543a033e36e71 /crates | |
| parent | e050356c9ba8e1a2c20d2fc842924e189f3cc89e (diff) | |
| download | php-shirabe-b5a9d37a7880b05cb3ba1fdbe5b8873295621514.tar.gz php-shirabe-b5a9d37a7880b05cb3ba1fdbe5b8873295621514.tar.zst php-shirabe-b5a9d37a7880b05cb3ba1fdbe5b8873295621514.zip | |
style: apply rustfmt to ported test files
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates')
13 files changed, 203 insertions, 51 deletions
diff --git a/crates/shirabe/tests/dependency_resolver/pool_test.rs b/crates/shirabe/tests/dependency_resolver/pool_test.rs index ef2cc8d..68a7f2a 100644 --- a/crates/shirabe/tests/dependency_resolver/pool_test.rs +++ b/crates/shirabe/tests/dependency_resolver/pool_test.rs @@ -28,7 +28,10 @@ fn test_pool() { let mut pool = create_pool(vec![package.clone()]); - assert!(same_packages(&[package.clone()], &pool.what_provides("foo", None))); + assert!(same_packages( + &[package.clone()], + &pool.what_provides("foo", None) + )); assert!(same_packages(&[package], &pool.what_provides("foo", None))); } diff --git a/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs b/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs index 306ce0c..ead80a3 100644 --- a/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs +++ b/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs @@ -18,7 +18,8 @@ fn test_from_bool_or_list() { ); // 'false creates IgnoreNothingFilter' - let filter = PlatformRequirementFilterFactory::from_bool_or_list(PhpMixed::Bool(false)).unwrap(); + let filter = + PlatformRequirementFilterFactory::from_bool_or_list(PhpMixed::Bool(false)).unwrap(); assert!( filter .as_any() diff --git a/crates/shirabe/tests/io/buffer_io_test.rs b/crates/shirabe/tests/io/buffer_io_test.rs index 67e6ab4..62abe0a 100644 --- a/crates/shirabe/tests/io/buffer_io_test.rs +++ b/crates/shirabe/tests/io/buffer_io_test.rs @@ -1,7 +1,7 @@ //! ref: composer/tests/Composer/Test/IO/BufferIOTest.php -use shirabe::io::buffer_io::BufferIO; use shirabe::io::IOInterfaceImmutable; +use shirabe::io::buffer_io::BufferIO; use shirabe_external_packages::symfony::console::output::output_interface::VERBOSITY_NORMAL; use shirabe_php_shim::PhpMixed; diff --git a/crates/shirabe/tests/package/version/version_bumper_test.rs b/crates/shirabe/tests/package/version/version_bumper_test.rs index 4e9bf92..08217f7 100644 --- a/crates/shirabe/tests/package/version/version_bumper_test.rs +++ b/crates/shirabe/tests/package/version/version_bumper_test.rs @@ -1,8 +1,8 @@ //! ref: composer/tests/Composer/Test/Package/Version/VersionBumperTest.php use indexmap::IndexMap; -use shirabe::package::package::Package; use shirabe::package::handle::{PackageHandle, PackageInterfaceHandle}; +use shirabe::package::package::Package; use shirabe::package::version::version_bumper::VersionBumper; use shirabe_php_shim::PhpMixed; use shirabe_semver::version_parser::VersionParser; @@ -36,7 +36,10 @@ fn test_bump_requirement() { let handle: PackageInterfaceHandle = PackageHandle::from_package(package).into(); let new_constraint = version_bumper - .bump_requirement(&version_parser.parse_constraints(requirement).unwrap(), handle) + .bump_requirement( + &version_parser.parse_constraints(requirement).unwrap(), + handle, + ) .unwrap(); // assert that the recommended version is what we expect @@ -44,8 +47,12 @@ fn test_bump_requirement() { } } -fn provide_bump_requirement_tests() -> Vec<(&'static str, &'static str, &'static str, Option<&'static str>)> -{ +fn provide_bump_requirement_tests() -> Vec<( + &'static str, + &'static str, + &'static str, + Option<&'static str>, +)> { // constraint, version, expected recommendation, [branch-alias] vec![ ("^1.0", "1.2.1", "^1.2.1", None), @@ -57,7 +64,12 @@ fn provide_bump_requirement_tests() -> Vec<(&'static str, &'static str, &'static ("^1.2 || ^2.3", "1.3.2", "^1.3.2 || ^2.3", None), ("^1.2 || ^2.3", "2.4.0", "^1.2 || ^2.4", None), ("^1.2 || ^2.3 || ^2", "2.4.0", "^1.2 || ^2.4 || ^2.4", None), - ("^1.2 || ^2.3.3 || ^2", "2.4.0", "^1.2 || ^2.4.0 || ^2.4", None), + ( + "^1.2 || ^2.3.3 || ^2", + "2.4.0", + "^1.2 || ^2.4.0 || ^2.4", + None, + ), ("^3@dev", "3.2.x-dev", "^3.2@dev", None), ("~2", "2.1-beta.1", "~2", None), ("dev-main", "dev-foo", "dev-main", None), diff --git a/crates/shirabe/tests/package/version/version_parser_test.rs b/crates/shirabe/tests/package/version/version_parser_test.rs index cddb382..b2ce409 100644 --- a/crates/shirabe/tests/package/version/version_parser_test.rs +++ b/crates/shirabe/tests/package/version/version_parser_test.rs @@ -20,7 +20,10 @@ fn test_parse_name_version_pairs() { for (input, result) in provide_parse_name_version_pairs_data() { let version_parser = VersionParser::new(); - assert_eq!(result, version_parser.parse_name_version_pairs(input).unwrap()); + assert_eq!( + result, + version_parser.parse_name_version_pairs(input).unwrap() + ); } } diff --git a/crates/shirabe/tests/platform/runtime_test.rs b/crates/shirabe/tests/platform/runtime_test.rs index a655c95..4c58404 100644 --- a/crates/shirabe/tests/platform/runtime_test.rs +++ b/crates/shirabe/tests/platform/runtime_test.rs @@ -6,7 +6,10 @@ use shirabe::platform::runtime::Runtime; #[ignore = "Runtime::parse_html_extension_info reaches a todo!() in the php-shim (html_entity_decode)"] fn test_parse_extension_info() { for (html_input, expected_output) in provide_extension_infos() { - assert_eq!(expected_output, Runtime::parse_html_extension_info(html_input)); + assert_eq!( + expected_output, + Runtime::parse_html_extension_info(html_input) + ); } } diff --git a/crates/shirabe/tests/util/config_validator_test.rs b/crates/shirabe/tests/util/config_validator_test.rs index dc39d66..da962e0 100644 --- a/crates/shirabe/tests/util/config_validator_test.rs +++ b/crates/shirabe/tests/util/config_validator_test.rs @@ -43,9 +43,12 @@ fn test_config_validator_commit_ref_warning() { fn test_config_validator_warns_on_script_description_for_nonexistent_script() { let warnings = validate(&fixture("composer_scripts-descriptions.json")); - assert!(warnings.contains( - &"Description for non-existent script \"phpcsxxx\" found in \"scripts-descriptions\"".to_string() - )); + assert!( + warnings.contains( + &"Description for non-existent script \"phpcsxxx\" found in \"scripts-descriptions\"" + .to_string() + ) + ); } #[test] diff --git a/crates/shirabe/tests/util/forgejo_url_test.rs b/crates/shirabe/tests/util/forgejo_url_test.rs index 17dae04..e29c05e 100644 --- a/crates/shirabe/tests/util/forgejo_url_test.rs +++ b/crates/shirabe/tests/util/forgejo_url_test.rs @@ -39,5 +39,8 @@ fn test_create_invalid() { fn test_generate_ssh_url() { let forgejo_url = ForgejoUrl::create("git@codeberg.org:acme/repo.git").unwrap(); - assert_eq!("git@codeberg.org:acme/repo.git", forgejo_url.generate_ssh_url()); + assert_eq!( + "git@codeberg.org:acme/repo.git", + forgejo_url.generate_ssh_url() + ); } diff --git a/crates/shirabe/tests/util/http/proxy_item_test.rs b/crates/shirabe/tests/util/http/proxy_item_test.rs index 4843945..0607bd5 100644 --- a/crates/shirabe/tests/util/http/proxy_item_test.rs +++ b/crates/shirabe/tests/util/http/proxy_item_test.rs @@ -56,6 +56,9 @@ fn data_formatting() -> Vec<(&'static str, &'static str)> { // 'removes-user' ("http://user@proxy.com:6180", "http://***@proxy.com:6180"), // 'removes-user-pass' - ("http://user:p%40ss@proxy.com:6180", "http://***:***@proxy.com:6180"), + ( + "http://user:p%40ss@proxy.com:6180", + "http://***:***@proxy.com:6180", + ), ] } diff --git a/crates/shirabe/tests/util/platform_test.rs b/crates/shirabe/tests/util/platform_test.rs index 3d00370..626e358 100644 --- a/crates/shirabe/tests/util/platform_test.rs +++ b/crates/shirabe/tests/util/platform_test.rs @@ -7,8 +7,14 @@ use shirabe_php_shim::defined; #[ignore = "Platform::expand_path does not read the env var set via put_env in this runtime"] fn test_expand_path() { Platform::put_env("TESTENV", "/home/test"); - assert_eq!("/home/test/myPath", Platform::expand_path("%TESTENV%/myPath")); - assert_eq!("/home/test/myPath", Platform::expand_path("$TESTENV/myPath")); + assert_eq!( + "/home/test/myPath", + Platform::expand_path("%TESTENV%/myPath") + ); + assert_eq!( + "/home/test/myPath", + Platform::expand_path("$TESTENV/myPath") + ); assert_eq!( format!( "{}/test", @@ -23,9 +29,6 @@ fn test_expand_path() { #[test] fn test_is_windows() { // Compare 2 common tests for Windows to the built-in Windows test - assert_eq!( - std::path::MAIN_SEPARATOR == '\\', - Platform::is_windows() - ); + assert_eq!(std::path::MAIN_SEPARATOR == '\\', Platform::is_windows()); assert_eq!(defined("PHP_WINDOWS_VERSION_MAJOR"), Platform::is_windows()); } diff --git a/crates/shirabe/tests/util/silencer_test.rs b/crates/shirabe/tests/util/silencer_test.rs index 42d0be4..c4e3baa 100644 --- a/crates/shirabe/tests/util/silencer_test.rs +++ b/crates/shirabe/tests/util/silencer_test.rs @@ -1,7 +1,9 @@ //! ref: composer/tests/Composer/Test/Util/SilencerTest.php use shirabe::util::silencer::Silencer; -use shirabe_php_shim::{E_USER_WARNING, RuntimeException, error_reporting, microtime, trigger_error}; +use shirabe_php_shim::{ + E_USER_WARNING, RuntimeException, error_reporting, microtime, trigger_error, +}; /// Test succeeds when no warnings are emitted externally, and original level is restored. #[test] diff --git a/crates/shirabe/tests/util/tar_test.rs b/crates/shirabe/tests/util/tar_test.rs index 3a8aa75..6234108 100644 --- a/crates/shirabe/tests/util/tar_test.rs +++ b/crates/shirabe/tests/util/tar_test.rs @@ -42,14 +42,20 @@ fn test_throws_exception_if_the_composer_json_is_in_a_sub_subfolder() { #[ignore = "PharData::new is todo!() in the php-shim"] fn test_returns_composer_json_in_tar_root() { let result = Tar::get_composer_json(&fixture("root.tar.gz")).unwrap(); - assert_eq!(Some("{\n \"name\": \"foo/bar\"\n}\n".to_string()), result); + assert_eq!( + Some("{\n \"name\": \"foo/bar\"\n}\n".to_string()), + result + ); } #[test] #[ignore = "PharData::new is todo!() in the php-shim"] fn test_returns_composer_json_in_first_folder() { let result = Tar::get_composer_json(&fixture("folder.tar.gz")).unwrap(); - assert_eq!(Some("{\n \"name\": \"foo/bar\"\n}\n".to_string()), result); + assert_eq!( + Some("{\n \"name\": \"foo/bar\"\n}\n".to_string()), + result + ); } #[test] diff --git a/crates/shirabe/tests/util/url_test.rs b/crates/shirabe/tests/util/url_test.rs index 025c7ee..cbbfb64 100644 --- a/crates/shirabe/tests/util/url_test.rs +++ b/crates/shirabe/tests/util/url_test.rs @@ -11,7 +11,11 @@ fn conf(entries: &[(&str, &[&str])]) -> IndexMap<String, PhpMixed> { .map(|(k, vals)| { ( k.to_string(), - PhpMixed::List(vals.iter().map(|v| PhpMixed::String(v.to_string())).collect()), + PhpMixed::List( + vals.iter() + .map(|v| PhpMixed::String(v.to_string())) + .collect(), + ), ) }) .collect() @@ -33,29 +37,108 @@ fn test_update_dist_reference() { } } -fn dist_refs_provider() -> Vec<(&'static str, &'static str, IndexMap<String, PhpMixed>, &'static str)> -{ +fn dist_refs_provider() -> Vec<( + &'static str, + &'static str, + IndexMap<String, PhpMixed>, + &'static str, +)> { vec![ // github - ("https://github.com/foo/bar/zipball/abcd", "https://api.github.com/repos/foo/bar/zipball/newref", conf(&[]), "newref"), - ("https://www.github.com/foo/bar/zipball/abcd", "https://api.github.com/repos/foo/bar/zipball/newref", conf(&[]), "newref"), - ("https://github.com/foo/bar/archive/abcd.zip", "https://api.github.com/repos/foo/bar/zipball/newref", conf(&[]), "newref"), - ("https://github.com/foo/bar/archive/abcd.tar.gz", "https://api.github.com/repos/foo/bar/tarball/newref", conf(&[]), "newref"), - ("https://api.github.com/repos/foo/bar/tarball", "https://api.github.com/repos/foo/bar/tarball/newref", conf(&[]), "newref"), - ("https://api.github.com/repos/foo/bar/tarball/abcd", "https://api.github.com/repos/foo/bar/tarball/newref", conf(&[]), "newref"), + ( + "https://github.com/foo/bar/zipball/abcd", + "https://api.github.com/repos/foo/bar/zipball/newref", + conf(&[]), + "newref", + ), + ( + "https://www.github.com/foo/bar/zipball/abcd", + "https://api.github.com/repos/foo/bar/zipball/newref", + conf(&[]), + "newref", + ), + ( + "https://github.com/foo/bar/archive/abcd.zip", + "https://api.github.com/repos/foo/bar/zipball/newref", + conf(&[]), + "newref", + ), + ( + "https://github.com/foo/bar/archive/abcd.tar.gz", + "https://api.github.com/repos/foo/bar/tarball/newref", + conf(&[]), + "newref", + ), + ( + "https://api.github.com/repos/foo/bar/tarball", + "https://api.github.com/repos/foo/bar/tarball/newref", + conf(&[]), + "newref", + ), + ( + "https://api.github.com/repos/foo/bar/tarball/abcd", + "https://api.github.com/repos/foo/bar/tarball/newref", + conf(&[]), + "newref", + ), // github enterprise - ("https://mygithub.com/api/v3/repos/foo/bar/tarball/abcd", "https://mygithub.com/api/v3/repos/foo/bar/tarball/newref", conf(&[("github-domains", &["mygithub.com"])]), "newref"), + ( + "https://mygithub.com/api/v3/repos/foo/bar/tarball/abcd", + "https://mygithub.com/api/v3/repos/foo/bar/tarball/newref", + conf(&[("github-domains", &["mygithub.com"])]), + "newref", + ), // bitbucket - ("https://bitbucket.org/foo/bar/get/abcd.zip", "https://bitbucket.org/foo/bar/get/newref.zip", conf(&[]), "newref"), - ("https://www.bitbucket.org/foo/bar/get/abcd.tar.bz2", "https://bitbucket.org/foo/bar/get/newref.tar.bz2", conf(&[]), "newref"), + ( + "https://bitbucket.org/foo/bar/get/abcd.zip", + "https://bitbucket.org/foo/bar/get/newref.zip", + conf(&[]), + "newref", + ), + ( + "https://www.bitbucket.org/foo/bar/get/abcd.tar.bz2", + "https://bitbucket.org/foo/bar/get/newref.tar.bz2", + conf(&[]), + "newref", + ), // gitlab - ("https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=abcd", "https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=newref", conf(&[]), "newref"), - ("https://www.gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=abcd", "https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=newref", conf(&[]), "newref"), - ("https://gitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.gz?sha=abcd", "https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=newref", conf(&[]), "newref"), + ( + "https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=abcd", + "https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=newref", + conf(&[]), + "newref", + ), + ( + "https://www.gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=abcd", + "https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.zip?sha=newref", + conf(&[]), + "newref", + ), + ( + "https://gitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.gz?sha=abcd", + "https://gitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=newref", + conf(&[]), + "newref", + ), // gitlab enterprise - ("https://mygitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=abcd", "https://mygitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=newref", conf(&[("gitlab-domains", &["mygitlab.com"])]), "newref"), - ("https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=abcd", "https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=newref", conf(&[("gitlab-domains", &["mygitlab.com"])]), "newref"), - ("https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=abcd", "https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=65", conf(&[("gitlab-domains", &["mygitlab.com"])]), "65"), + ( + "https://mygitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=abcd", + "https://mygitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=newref", + conf(&[("gitlab-domains", &["mygitlab.com"])]), + "newref", + ), + ( + "https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=abcd", + "https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=newref", + conf(&[("gitlab-domains", &["mygitlab.com"])]), + "newref", + ), + ( + "https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=abcd", + "https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=65", + conf(&[("gitlab-domains", &["mygitlab.com"])]), + "65", + ), ] } @@ -70,22 +153,49 @@ fn test_sanitize() { fn sanitize_provider() -> Vec<(&'static str, &'static str)> { vec![ // with scheme - ("https://foo:***@example.org/", "https://foo:bar@example.org/"), + ( + "https://foo:***@example.org/", + "https://foo:bar@example.org/", + ), ("https://foo@example.org/", "https://foo@example.org/"), ("https://example.org/", "https://example.org/"), - ("http://***:***@example.org", "http://10a8f08e8d7b7b9:foo@example.org"), - ("https://foo:***@example.org:123/", "https://foo:bar@example.org:123/"), - ("https://example.org/foo/bar?access_token=***", "https://example.org/foo/bar?access_token=abcdef"), - ("https://example.org/foo/bar?foo=bar&access_token=***", "https://example.org/foo/bar?foo=bar&access_token=abcdef"), - ("https://***:***@github.com/acme/repo", "https://ghp_1234567890abcdefghijklmnopqrstuvwxyzAB:x-oauth-basic@github.com/acme/repo"), - ("https://***:***@github.com/acme/repo", "https://github_pat_1234567890abcdefghijkl_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW:x-oauth-basic@github.com/acme/repo"), + ( + "http://***:***@example.org", + "http://10a8f08e8d7b7b9:foo@example.org", + ), + ( + "https://foo:***@example.org:123/", + "https://foo:bar@example.org:123/", + ), + ( + "https://example.org/foo/bar?access_token=***", + "https://example.org/foo/bar?access_token=abcdef", + ), + ( + "https://example.org/foo/bar?foo=bar&access_token=***", + "https://example.org/foo/bar?foo=bar&access_token=abcdef", + ), + ( + "https://***:***@github.com/acme/repo", + "https://ghp_1234567890abcdefghijklmnopqrstuvwxyzAB:x-oauth-basic@github.com/acme/repo", + ), + ( + "https://***:***@github.com/acme/repo", + "https://github_pat_1234567890abcdefghijkl_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW:x-oauth-basic@github.com/acme/repo", + ), // without scheme ("foo:***@example.org/", "foo:bar@example.org/"), ("foo@example.org/", "foo@example.org/"), ("example.org/", "example.org/"), ("***:***@example.org", "10a8f08e8d7b7b9:foo@example.org"), ("foo:***@example.org:123/", "foo:bar@example.org:123/"), - ("example.org/foo/bar?access_token=***", "example.org/foo/bar?access_token=abcdef"), - ("example.org/foo/bar?foo=bar&access_token=***", "example.org/foo/bar?foo=bar&access_token=abcdef"), + ( + "example.org/foo/bar?access_token=***", + "example.org/foo/bar?access_token=abcdef", + ), + ( + "example.org/foo/bar?foo=bar&access_token=***", + "example.org/foo/bar?foo=bar&access_token=abcdef", + ), ] } |
