diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-22 02:09:59 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-22 02:09:59 +0900 |
| commit | 822d9a872807a92a5337ee8b7bab96dc9845cdbb (patch) | |
| tree | 4931365df5978caffade69cad2154718a9076f66 /crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs | |
| parent | f691b864b687f251c3b266e8cff2774d730567ba (diff) | |
| download | php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.tar.gz php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.tar.zst php-shirabe-822d9a872807a92a5337ee8b7bab96dc9845cdbb.zip | |
test: port more test cases
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs')
| -rw-r--r-- | crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs | 112 |
1 files changed, 91 insertions, 21 deletions
diff --git a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs index 1e13ada..0333a2b 100644 --- a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs @@ -1,107 +1,177 @@ //! 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. +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::repository::vcs::GitLabDriver; +use shirabe_php_shim::{PhpMixed, extension_loaded}; + +// Mirrors GitLabDriverTest::setUp's `gitlab-domains` configuration. +fn make_config() -> Config { + let mut config = Config::new(true, None); + let mut top: IndexMap<String, PhpMixed> = IndexMap::new(); + let mut config_section: IndexMap<String, PhpMixed> = IndexMap::new(); + config_section.insert( + "gitlab-domains".to_string(), + PhpMixed::List(vec![ + PhpMixed::String("mycompany.com/gitlab".to_string()), + PhpMixed::String("gitlab.mycompany.com".to_string()), + PhpMixed::String("othercompany.com/nested/gitlab".to_string()), + PhpMixed::String("gitlab.com".to_string()), + PhpMixed::String("gitlab.mycompany.local".to_string()), + ]), + ); + top.insert("config".to_string(), PhpMixed::Array(config_section)); + config.merge(&top, Config::SOURCE_UNKNOWN); + config +} #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_initialize() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_initialize_public_project() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_initialize_public_project_as_anonymous() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_initialize_with_port_number() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "depends on testInitialize, which needs HttpDownloaderMock + setAttribute (\\ReflectionProperty) not ported"] fn test_invalid_support_data() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "depends on testInitialize, which needs HttpDownloaderMock + the IOInterface MockObject not ported"] fn test_get_dist() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "depends on testInitialize, which needs HttpDownloaderMock + the IOInterface MockObject not ported"] fn test_get_source() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "depends on testInitializePublicProject, which needs HttpDownloaderMock + the IOInterface MockObject not ported"] fn test_get_source_given_public_project() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "depends on testInitialize, which needs HttpDownloaderMock + the IOInterface MockObject not ported"] fn test_get_tags() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "depends on testInitialize, which needs HttpDownloaderMock + the IOInterface MockObject not ported"] fn test_get_paginated_refs() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "depends on testInitialize, which needs HttpDownloaderMock + the IOInterface MockObject not ported"] fn test_get_branches() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore] fn test_supports() { - todo!() + for (url, expected) in data_for_test_supports() { + let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let config = Rc::new(RefCell::new(make_config())); + + assert_eq!( + expected, + GitLabDriver::supports(io, config, url, false).unwrap() + ); + } +} + +fn data_for_test_supports() -> Vec<(&'static str, bool)> { + let openssl = extension_loaded("openssl"); + vec![ + ("http://gitlab.com/foo/bar", true), + ("http://gitlab.mycompany.com:5443/foo/bar", true), + ("http://gitlab.com/foo/bar/", true), + ("http://gitlab.com/foo/bar/", true), + ("http://gitlab.com/foo/bar.git", true), + ("http://gitlab.com/foo/bar.git", true), + ("http://gitlab.com/foo/bar.baz.git", true), + ("https://gitlab.com/foo/bar", openssl), + ("https://gitlab.mycompany.com:5443/foo/bar", openssl), + ("git@gitlab.com:foo/bar.git", openssl), + ("git@example.com:foo/bar.git", false), + ("http://example.com/foo/bar", false), + ("http://mycompany.com/gitlab/mygroup/myproject", true), + ("https://mycompany.com/gitlab/mygroup/myproject", openssl), + ( + "http://othercompany.com/nested/gitlab/mygroup/myproject", + true, + ), + ( + "https://othercompany.com/nested/gitlab/mygroup/myproject", + openssl, + ), + ( + "http://gitlab.com/mygroup/mysubgroup/mysubsubgroup/myproject", + true, + ), + ( + "https://gitlab.com/mygroup/mysubgroup/mysubsubgroup/myproject", + openssl, + ), + ] } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_gitlab_sub_directory() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_gitlab_sub_group() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_gitlab_sub_directory_sub_group() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_forwards_options() { todo!() } #[test] -#[ignore = "GitLabDriver tests mock HttpDownloader/IO (curl_multi_init todo!()) or need setUp gitlab-domains config"] +#[ignore = "HttpDownloaderMock (getHttpDownloaderMock) and the IOInterface MockObject are not ported"] fn test_protocol_override_repository_url_generation() { todo!() } |
