aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/util
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 03:16:34 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 03:17:45 +0900
commit903d37a254f931e79ecded26f30a3b517c6d27da (patch)
tree4cd32e55466dd463e10aef35e8fad239dd08938a /crates/shirabe/tests/util
parentd9eb06c836e1faa759225a9653181b1dcd38a52d (diff)
downloadphp-shirabe-903d37a254f931e79ecded26f30a3b517c6d27da.tar.gz
php-shirabe-903d37a254f931e79ecded26f30a3b517c6d27da.tar.zst
php-shirabe-903d37a254f931e79ecded26f30a3b517c6d27da.zip
test(repository): port InstalledRepositoryTest
testAddRepository maps the expected LogicException to #[should_panic] since InstalledRepository::add_repository guards with assert!. testFindPackagesWithReplacersAndProviders is #[ignore] because that assert omits InstalledRepositoryInterface, so adding an InstalledArrayRepository panics before the lookup runs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/util')
-rw-r--r--crates/shirabe/tests/util/http/request_proxy_test.rs53
-rw-r--r--crates/shirabe/tests/util/package_sorter_test.rs7
-rw-r--r--crates/shirabe/tests/util/zip_test.rs15
3 files changed, 60 insertions, 15 deletions
diff --git a/crates/shirabe/tests/util/http/request_proxy_test.rs b/crates/shirabe/tests/util/http/request_proxy_test.rs
index 3674396..502ec31 100644
--- a/crates/shirabe/tests/util/http/request_proxy_test.rs
+++ b/crates/shirabe/tests/util/http/request_proxy_test.rs
@@ -64,7 +64,11 @@ fn test_get_status() {
let cases: Vec<(Option<&str>, Option<&str>, &str)> = vec![
(None, Some(format), ""),
(Some("http://proxy.com:80"), None, "http://proxy.com:80"),
- (Some("http://proxy.com:80"), Some(format), "proxy (http://proxy.com:80)"),
+ (
+ Some("http://proxy.com:80"),
+ Some(format),
+ "proxy (http://proxy.com:80)",
+ ),
];
for (url, format, expected) in cases {
@@ -92,7 +96,10 @@ fn test_get_curl_options() {
Some("http://proxy.com:80"),
None,
curl_options(&[
- (CURLOPT_PROXY, PhpMixed::String("http://proxy.com:80".to_string())),
+ (
+ CURLOPT_PROXY,
+ PhpMixed::String("http://proxy.com:80".to_string()),
+ ),
(CURLOPT_NOPROXY, PhpMixed::String(String::new())),
]),
),
@@ -100,10 +107,16 @@ fn test_get_curl_options() {
Some("http://proxy.com:80"),
Some("user:p%40ss"),
curl_options(&[
- (CURLOPT_PROXY, PhpMixed::String("http://proxy.com:80".to_string())),
+ (
+ CURLOPT_PROXY,
+ PhpMixed::String("http://proxy.com:80".to_string()),
+ ),
(CURLOPT_NOPROXY, PhpMixed::String(String::new())),
(CURLOPT_PROXYAUTH, PhpMixed::Int(CURLAUTH_BASIC)),
- (CURLOPT_PROXYUSERPWD, PhpMixed::String("user:p%40ss".to_string())),
+ (
+ CURLOPT_PROXYUSERPWD,
+ PhpMixed::String("user:p%40ss".to_string()),
+ ),
]),
),
];
@@ -118,20 +131,34 @@ fn test_get_curl_options() {
#[ignore = "secure proxies require curl_version, which is a todo!() in the php-shim"]
fn test_get_curl_options_with_ssl() {
let mut cafile_opts: IndexMap<String, PhpMixed> = IndexMap::new();
- cafile_opts.insert("cafile".to_string(), PhpMixed::String("/certs/bundle.pem".to_string()));
+ cafile_opts.insert(
+ "cafile".to_string(),
+ PhpMixed::String("/certs/bundle.pem".to_string()),
+ );
let mut capath_opts: IndexMap<String, PhpMixed> = IndexMap::new();
capath_opts.insert("capath".to_string(), PhpMixed::String("/certs".to_string()));
- let cases: Vec<(&str, Option<&str>, IndexMap<String, PhpMixed>, IndexMap<i64, PhpMixed>)> = vec![
+ let cases: Vec<(
+ &str,
+ Option<&str>,
+ IndexMap<String, PhpMixed>,
+ IndexMap<i64, PhpMixed>,
+ )> = vec![
(
"https://proxy.com:443",
None,
cafile_opts,
curl_options(&[
- (CURLOPT_PROXY, PhpMixed::String("https://proxy.com:443".to_string())),
+ (
+ CURLOPT_PROXY,
+ PhpMixed::String("https://proxy.com:443".to_string()),
+ ),
(CURLOPT_NOPROXY, PhpMixed::String(String::new())),
- (CURLOPT_PROXY_CAINFO, PhpMixed::String("/certs/bundle.pem".to_string())),
+ (
+ CURLOPT_PROXY_CAINFO,
+ PhpMixed::String("/certs/bundle.pem".to_string()),
+ ),
]),
),
(
@@ -139,10 +166,16 @@ fn test_get_curl_options_with_ssl() {
Some("user:p%40ss"),
capath_opts,
curl_options(&[
- (CURLOPT_PROXY, PhpMixed::String("https://proxy.com:443".to_string())),
+ (
+ CURLOPT_PROXY,
+ PhpMixed::String("https://proxy.com:443".to_string()),
+ ),
(CURLOPT_NOPROXY, PhpMixed::String(String::new())),
(CURLOPT_PROXYAUTH, PhpMixed::Int(CURLAUTH_BASIC)),
- (CURLOPT_PROXYUSERPWD, PhpMixed::String("user:p%40ss".to_string())),
+ (
+ CURLOPT_PROXYUSERPWD,
+ PhpMixed::String("user:p%40ss".to_string()),
+ ),
(CURLOPT_PROXY_CAPATH, PhpMixed::String("/certs".to_string())),
]),
),
diff --git a/crates/shirabe/tests/util/package_sorter_test.rs b/crates/shirabe/tests/util/package_sorter_test.rs
index 41770e0..1b95824 100644
--- a/crates/shirabe/tests/util/package_sorter_test.rs
+++ b/crates/shirabe/tests/util/package_sorter_test.rs
@@ -47,8 +47,11 @@ fn test_sorting_does_nothing_with_no_dependencies() {
assert_eq!(expected, names(&sorted_packages));
}
-fn sorting_orders_dependencies_higher_than_package_cases()
--> Vec<(Vec<PackageInterfaceHandle>, Vec<&'static str>, IndexMap<String, i64>)> {
+fn sorting_orders_dependencies_higher_than_package_cases() -> Vec<(
+ Vec<PackageInterfaceHandle>,
+ Vec<&'static str>,
+ IndexMap<String, i64>,
+)> {
vec![
// one package is dep
(
diff --git a/crates/shirabe/tests/util/zip_test.rs b/crates/shirabe/tests/util/zip_test.rs
index 07f5629..b80dd17 100644
--- a/crates/shirabe/tests/util/zip_test.rs
+++ b/crates/shirabe/tests/util/zip_test.rs
@@ -50,7 +50,10 @@ fn test_throws_exception_if_the_composer_json_is_in_a_sub_subfolder() {
fn test_returns_composer_json_in_zip_root() {
let result = Zip::get_composer_json(&fixture("root.zip")).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]
@@ -58,7 +61,10 @@ fn test_returns_composer_json_in_zip_root() {
fn test_returns_composer_json_in_first_folder() {
let result = Zip::get_composer_json(&fixture("folder.zip")).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]
@@ -72,5 +78,8 @@ fn test_multiple_top_level_dirs_is_invalid() {
fn test_returns_composer_json_from_first_subfolder() {
let result = Zip::get_composer_json(&fixture("single-sub.zip")).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
+ );
}