aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/util/svn_test.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-22 23:42:07 +0900
committernsfisis <nsfisis@gmail.com>2026-06-22 23:42:07 +0900
commit5ab5f3b316798c1411ce8e6a7f5b091fda93589c (patch)
treec7669f94f5d9bd9adc07bc1aab3f14cfdec1ae5f /crates/shirabe/tests/util/svn_test.rs
parentb291e714bc739262140323e08fe2fb9e91e00ee7 (diff)
downloadphp-shirabe-5ab5f3b316798c1411ce8e6a7f5b091fda93589c.tar.gz
php-shirabe-5ab5f3b316798c1411ce8e6a7f5b091fda93589c.tar.zst
php-shirabe-5ab5f3b316798c1411ce8e6a7f5b091fda93589c.zip
test: port previously-ignored Composer tests via __ test hatches
Re-evaluate the reason'd #[ignore] tests under the Phase D criterion: a test is unportable ONLY if the APIs/types needed to WRITE it do not exist. A test that compiles but panics at runtime (todo!() body, a regex the regex crate cannot compile) or fails at runtime (incomplete or incorrect impl behavior) is portable -- it is written in full and marked with a reason-less #[ignore]. About 120 test functions move from reason'd #[ignore] to reason-less #[ignore] (the ported-but-not-yet-passing signal). Impl crates gain only additive __ test hatches (init_command, pool, file_downloader, package handle link setters, artifact/path repository, repository manager, svn); no existing logic changes. Tests whose required APIs genuinely do not exist (mock/reflection harness, ApplicationTester, solve() discarding SolverProblemsException, a script::Event that cannot be passed as an originating event) keep their reason'd #[ignore]. cargo check -p shirabe --tests passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/util/svn_test.rs')
-rw-r--r--crates/shirabe/tests/util/svn_test.rs134
1 files changed, 124 insertions, 10 deletions
diff --git a/crates/shirabe/tests/util/svn_test.rs b/crates/shirabe/tests/util/svn_test.rs
index 90a6b45..25e3f4e 100644
--- a/crates/shirabe/tests/util/svn_test.rs
+++ b/crates/shirabe/tests/util/svn_test.rs
@@ -1,31 +1,145 @@
//! ref: composer/tests/Composer/Test/Util/SvnTest.php
-#[ignore = "Svn::get_credential_args is pub(crate) (crate-private); unreachable from an integration test"]
+use std::cell::RefCell;
+use std::rc::Rc;
+
+use indexmap::IndexMap;
+use shirabe::config::Config;
+use shirabe::io::IOInterface;
+use shirabe::io::null_io::NullIO;
+use shirabe::util::svn::Svn;
+use shirabe_php_shim::PhpMixed;
+
+fn map(pairs: Vec<(&str, PhpMixed)>) -> IndexMap<String, PhpMixed> {
+ pairs.into_iter().map(|(k, v)| (k.to_string(), v)).collect()
+}
+
+/// Builds a `['config' => ['http-basic' => [host => ['username' => .., 'password' => ..]]]]`
+/// map for `Config::merge`.
+fn http_basic_config(host: &str, username: &str, password: &str) -> IndexMap<String, PhpMixed> {
+ let creds = map(vec![
+ ("username", PhpMixed::String(username.to_string())),
+ ("password", PhpMixed::String(password.to_string())),
+ ]);
+ let http_basic = map(vec![(host, PhpMixed::Array(creds))]);
+ let config = map(vec![("http-basic", PhpMixed::Array(http_basic))]);
+ map(vec![("config", PhpMixed::Array(config))])
+}
+
+/// ref: SvnTest::urlProvider
+fn url_provider() -> Vec<(&'static str, Vec<&'static str>)> {
+ vec![
+ (
+ "http://till:test@svn.example.org/",
+ vec!["--username", "till", "--password", "test"],
+ ),
+ ("http://svn.apache.org/", vec![]),
+ (
+ "svn://johndoe@example.org",
+ vec!["--username", "johndoe", "--password", ""],
+ ),
+ ]
+}
+
#[test]
+#[ignore]
fn test_credentials() {
- todo!()
+ for (url, expect) in url_provider() {
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let config = Rc::new(RefCell::new(Config::new(true, None)));
+ let mut svn = Svn::new(url.to_string(), io, config, None);
+
+ let expect: Vec<String> = expect.iter().map(|s| s.to_string()).collect();
+ assert_eq!(expect, svn.__get_credential_args());
+ }
}
-#[ignore = "Svn::get_command is pub(crate) (crate-private); unreachable from an integration test"]
#[test]
+#[ignore]
fn test_interactive_string() {
- todo!()
+ let url = "http://svn.example.org";
+
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let config = Rc::new(RefCell::new(Config::new(true, None)));
+ let mut svn = Svn::new(url.to_string(), io, config, None);
+
+ assert_eq!(
+ vec![
+ "svn".to_string(),
+ "ls".to_string(),
+ "--non-interactive".to_string(),
+ "--".to_string(),
+ "http://svn.example.org".to_string(),
+ ],
+ svn.__get_command(vec!["svn".to_string(), "ls".to_string()], url, None)
+ );
}
-#[ignore = "Svn::get_credential_args is pub(crate) (crate-private); unreachable from an integration test"]
#[test]
+#[ignore]
fn test_credentials_from_config() {
- todo!()
+ let url = "http://svn.apache.org";
+
+ let mut config = Config::new(true, None);
+ config.merge(&http_basic_config("svn.apache.org", "foo", "bar"), "test");
+
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let mut svn = Svn::new(url.to_string(), io, Rc::new(RefCell::new(config)), None);
+
+ assert_eq!(
+ vec![
+ "--username".to_string(),
+ "foo".to_string(),
+ "--password".to_string(),
+ "bar".to_string(),
+ ],
+ svn.__get_credential_args()
+ );
}
-#[ignore = "Svn::get_credential_args is pub(crate) (crate-private); unreachable from an integration test"]
#[test]
+#[ignore]
fn test_credentials_from_config_with_cache_credentials_true() {
- todo!()
+ let url = "http://svn.apache.org";
+
+ let mut config = Config::new(true, None);
+ config.merge(&http_basic_config("svn.apache.org", "foo", "bar"), "test");
+
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let mut svn = Svn::new(url.to_string(), io, Rc::new(RefCell::new(config)), None);
+ svn.set_cache_credentials(true);
+
+ assert_eq!(
+ vec![
+ "--username".to_string(),
+ "foo".to_string(),
+ "--password".to_string(),
+ "bar".to_string(),
+ ],
+ svn.__get_credential_args()
+ );
}
-#[ignore = "Svn::get_credential_args is pub(crate) (crate-private); unreachable from an integration test"]
#[test]
+#[ignore]
fn test_credentials_from_config_with_cache_credentials_false() {
- todo!()
+ let url = "http://svn.apache.org";
+
+ let mut config = Config::new(true, None);
+ config.merge(&http_basic_config("svn.apache.org", "foo", "bar"), "test");
+
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let mut svn = Svn::new(url.to_string(), io, Rc::new(RefCell::new(config)), None);
+ svn.set_cache_credentials(false);
+
+ assert_eq!(
+ vec![
+ "--no-auth-cache".to_string(),
+ "--username".to_string(),
+ "foo".to_string(),
+ "--password".to_string(),
+ "bar".to_string(),
+ ],
+ svn.__get_credential_args()
+ );
}