aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 04:41:01 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 04:41:01 +0900
commita5b5366492d87ebf3fd0b1aaf77c15dfa978ae95 (patch)
treeaf993f05750537f53b9cbce3457715128599f0ea /crates/shirabe/tests
parent46ff68a20235cb6ba05d00b001f334abc303eef8 (diff)
downloadphp-shirabe-a5b5366492d87ebf3fd0b1aaf77c15dfa978ae95.tar.gz
php-shirabe-a5b5366492d87ebf3fd0b1aaf77c15dfa978ae95.tar.zst
php-shirabe-a5b5366492d87ebf3fd0b1aaf77c15dfa978ae95.zip
test(repository): port VCS driver tests (Git/GitHub/GitLab/Bitbucket/Svn/Perforce/Forgejo)
Svn/GitBitbucket/Perforce supports pass. GitHub::supports reaches non-strict in_array (todo!()) and Forgejo::supports uses a regex the regex crate cannot compile, so those are ignored. All API-driven cases mock the HttpDownloader (curl) / ProcessExecutor and are stubbed. setUp/tearDown not ported. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests')
-rw-r--r--crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs56
-rw-r--r--crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs73
-rw-r--r--crates/shirabe/tests/repository/vcs/git_driver_test.rs21
-rw-r--r--crates/shirabe/tests/repository/vcs/github_driver_test.rs89
-rw-r--r--crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs32
-rw-r--r--crates/shirabe/tests/repository/vcs/mod.rs7
-rw-r--r--crates/shirabe/tests/repository/vcs/perforce_driver_test.rs48
-rw-r--r--crates/shirabe/tests/repository/vcs/svn_driver_test.rs35
8 files changed, 361 insertions, 0 deletions
diff --git a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
index 9b9760a..f488182 100644
--- a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
@@ -1 +1,57 @@
//! ref: composer/tests/Composer/Test/Repository/Vcs/ForgejoDriverTest.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::ForgejoDriver;
+
+fn supports_provider() -> Vec<(bool, &'static str)> {
+ vec![
+ (false, "https://example.org/acme/repo"),
+ (true, "https://codeberg.org/acme/repository"),
+ ]
+}
+
+#[test]
+#[ignore = "ForgejoDriver::supports uses a regex with a character class the regex crate cannot compile (unclosed character class)"]
+fn test_supports() {
+ for (expected, repo_url) in supports_provider() {
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let config = Rc::new(RefCell::new(Config::new(true, None)));
+
+ assert_eq!(
+ expected,
+ ForgejoDriver::supports(io, config, repo_url, false).unwrap()
+ );
+ }
+}
+
+// The remaining cases construct a ForgejoDriver and mock the HttpDownloader to return
+// Forgejo API responses; mocking is not available, and a real HttpDownloader reaches
+// curl_multi_init (todo!()).
+#[test]
+#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_public_repository() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_get_branches() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_get_tags() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a ForgejoDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_get_empty_file_content() {
+ todo!()
+}
diff --git a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
index 2c6d427..e48c609 100644
--- a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
@@ -1 +1,74 @@
//! ref: composer/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.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::GitBitbucketDriver;
+
+#[test]
+fn test_supports() {
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let config = Rc::new(RefCell::new(Config::new(true, None)));
+
+ assert!(
+ GitBitbucketDriver::supports(
+ io.clone(),
+ config.clone(),
+ "https://bitbucket.org/user/repo.git",
+ false
+ )
+ .unwrap()
+ );
+
+ // should not be changed, see https://github.com/composer/composer/issues/9400
+ assert!(
+ !GitBitbucketDriver::supports(
+ io.clone(),
+ config.clone(),
+ "git@bitbucket.org:user/repo.git",
+ false
+ )
+ .unwrap()
+ );
+
+ assert!(
+ !GitBitbucketDriver::supports(io, config, "https://github.com/user/repo.git", false)
+ .unwrap()
+ );
+}
+
+// The remaining cases construct a GitBitbucketDriver and mock the HttpDownloader to return
+// Bitbucket API responses; mocking is not available, and a real HttpDownloader reaches
+// curl_multi_init (todo!()).
+#[test]
+#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_get_root_identifier_wrong_scm_type() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_driver() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_get_params() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_initialize_invalid_repository_url() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitBitbucketDriver and mocks the HttpDownloader (curl_multi_init todo!())"]
+fn test_invalid_support_data() {
+ todo!()
+}
diff --git a/crates/shirabe/tests/repository/vcs/git_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_driver_test.rs
index c915947..85c9f0b 100644
--- a/crates/shirabe/tests/repository/vcs/git_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/git_driver_test.rs
@@ -1 +1,22 @@
//! ref: composer/tests/Composer/Test/Repository/Vcs/GitDriverTest.php
+
+// Every case constructs a GitDriver with a mocked ProcessExecutor (and an HttpDownloader
+// that reaches curl_multi_init, todo!()) to feed git command output; mocking is not
+// available here.
+
+macro_rules! git_stub {
+ ($name:ident) => {
+ #[test]
+ #[ignore = "constructs a GitDriver and mocks a ProcessExecutor/HttpDownloader (curl_multi_init todo!())"]
+ fn $name() {
+ todo!()
+ }
+ };
+}
+
+git_stub!(test_get_root_identifier_from_remote_local_repository);
+git_stub!(test_get_root_identifier_from_remote);
+git_stub!(test_get_root_identifier_from_local_with_network_disabled);
+git_stub!(test_get_branches_filter_invalid_branch_names);
+git_stub!(test_file_get_content_invalid_identifier);
+git_stub!(test_get_change_date_invalid_identifier);
diff --git a/crates/shirabe/tests/repository/vcs/github_driver_test.rs b/crates/shirabe/tests/repository/vcs/github_driver_test.rs
index fd27768..d0067d5 100644
--- a/crates/shirabe/tests/repository/vcs/github_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/github_driver_test.rs
@@ -1 +1,90 @@
//! ref: composer/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.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::GitHubDriver;
+
+fn supports_provider() -> Vec<(bool, &'static str)> {
+ vec![
+ (false, "https://github.com/acme"),
+ (true, "https://github.com/acme/repository"),
+ (true, "git@github.com:acme/repository.git"),
+ (false, "https://github.com/acme/repository/releases"),
+ (false, "https://github.com/acme/repository/pulls"),
+ ]
+}
+
+#[test]
+#[ignore = "GitHubDriver::supports reaches non-strict in_array, which is todo!() in the php-shim"]
+fn test_supports() {
+ for (expected, repo_url) in supports_provider() {
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let config = Rc::new(RefCell::new(Config::new(true, None)));
+
+ assert_eq!(
+ expected,
+ GitHubDriver::supports(io, config, repo_url, false).unwrap()
+ );
+ }
+}
+
+// The remaining cases construct a GitHubDriver and mock the HttpDownloader/IO to return
+// GitHub API responses; mocking is not available, and a real HttpDownloader reaches
+// curl_multi_init (todo!()).
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_private_repository() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_public_repository() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_public_repository2() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_invalid_support_data() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_funding_format() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_public_repository_archived() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_private_repository_no_interaction() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_initialize_invalid_repo_url() {
+ todo!()
+}
+
+#[test]
+#[ignore = "constructs a GitHubDriver and mocks the HttpDownloader/IO (curl_multi_init todo!())"]
+fn test_get_empty_file_content() {
+ todo!()
+}
diff --git a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
index 7543394..a9432c4 100644
--- a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
@@ -1 +1,33 @@
//! ref: composer/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php
+
+// All cases either mock the HttpDownloader/IO to return GitLab API responses (a real
+// HttpDownloader reaches curl_multi_init, todo!()), or — for testSupports — rely on the
+// gitlab-domains configured in setUp plus the openssl extension, which are not modeled.
+
+macro_rules! gitlab_stub {
+ ($name:ident) => {
+ #[test]
+ #[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"]
+ fn $name() {
+ todo!()
+ }
+ };
+}
+
+gitlab_stub!(test_initialize);
+gitlab_stub!(test_initialize_public_project);
+gitlab_stub!(test_initialize_public_project_as_anonymous);
+gitlab_stub!(test_initialize_with_port_number);
+gitlab_stub!(test_invalid_support_data);
+gitlab_stub!(test_get_dist);
+gitlab_stub!(test_get_source);
+gitlab_stub!(test_get_source_given_public_project);
+gitlab_stub!(test_get_tags);
+gitlab_stub!(test_get_paginated_refs);
+gitlab_stub!(test_get_branches);
+gitlab_stub!(test_supports);
+gitlab_stub!(test_gitlab_sub_directory);
+gitlab_stub!(test_gitlab_sub_group);
+gitlab_stub!(test_gitlab_sub_directory_sub_group);
+gitlab_stub!(test_forwards_options);
+gitlab_stub!(test_protocol_override_repository_url_generation);
diff --git a/crates/shirabe/tests/repository/vcs/mod.rs b/crates/shirabe/tests/repository/vcs/mod.rs
index 474f388..5026320 100644
--- a/crates/shirabe/tests/repository/vcs/mod.rs
+++ b/crates/shirabe/tests/repository/vcs/mod.rs
@@ -1,2 +1,9 @@
+mod forgejo_driver_test;
mod fossil_driver_test;
+mod git_bitbucket_driver_test;
+mod git_driver_test;
+mod github_driver_test;
+mod gitlab_driver_test;
mod hg_driver_test;
+mod perforce_driver_test;
+mod svn_driver_test;
diff --git a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs
index 68e251f..c8353de 100644
--- a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs
@@ -1 +1,49 @@
//! ref: composer/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.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::PerforceDriver;
+
+#[test]
+fn test_supports_returns_false_no_deep_check() {
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let config = Rc::new(RefCell::new(Config::new(true, None)));
+
+ assert!(!PerforceDriver::supports(io, config, "existing.url", false).unwrap());
+}
+
+// The remaining cases mock Perforce, the repository config and IO to drive initialization,
+// composer-file detection and cleanup; mocking is not available here.
+#[test]
+#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
+fn test_initialize_captures_variables_from_repo_config() {
+ todo!()
+}
+
+#[test]
+#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
+fn test_initialize_logs_in_and_connects_client() {
+ todo!()
+}
+
+#[test]
+#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
+fn test_has_composer_file_returns_false_on_no_composer_file() {
+ todo!()
+}
+
+#[test]
+#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
+fn test_has_composer_file_returns_true_with_one_or_more_composer_files() {
+ todo!()
+}
+
+#[test]
+#[ignore = "mocks Perforce/repository/IO; mocking is not available"]
+fn test_cleanup() {
+ todo!()
+}
diff --git a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
index ad85dc7..64108c6 100644
--- a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
@@ -1 +1,36 @@
//! ref: composer/tests/Composer/Test/Repository/Vcs/SvnDriverTest.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::SvnDriver;
+
+fn support_provider() -> Vec<(&'static str, bool)> {
+ vec![
+ ("http://svn.apache.org", true),
+ ("https://svn.sf.net", true),
+ ("svn://example.org", true),
+ ("svn+ssh://example.org", true),
+ ]
+}
+
+#[test]
+fn test_support() {
+ for (url, assertion) in support_provider() {
+ let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new()));
+ let config = Rc::new(RefCell::new(Config::new(true, None)));
+
+ assert_eq!(assertion, SvnDriver::supports(io, config, url, false).unwrap());
+ }
+}
+
+// Constructs an SvnDriver and runs an svn command via a mocked ProcessExecutor; mocking is
+// not available here.
+#[test]
+#[ignore = "constructs an SvnDriver and mocks a ProcessExecutor for the svn invocation"]
+fn test_wrong_credentials_in_url() {
+ todo!()
+}