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/downloader | |
| 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/downloader')
9 files changed, 172 insertions, 88 deletions
diff --git a/crates/shirabe/tests/downloader/archive_downloader_test.rs b/crates/shirabe/tests/downloader/archive_downloader_test.rs index 2c0e2de..dfba3bf 100644 --- a/crates/shirabe/tests/downloader/archive_downloader_test.rs +++ b/crates/shirabe/tests/downloader/archive_downloader_test.rs @@ -5,37 +5,37 @@ // packages. #[test] -#[ignore = "constructs an ArchiveDownloader (HttpDownloader reaches curl_multi_init, todo!()) with a mocked subclass/package"] +#[ignore = "FileDownloader::get_file_name is pub(crate); not reachable from the integration test crate"] fn test_get_file_name() { todo!() } #[test] -#[ignore = "constructs an ArchiveDownloader (HttpDownloader reaches curl_multi_init, todo!()) with a mocked subclass/package"] +#[ignore = "FileDownloader::process_url is pub(crate); not reachable from the integration test crate"] fn test_process_url() { todo!() } #[test] -#[ignore = "constructs an ArchiveDownloader (HttpDownloader reaches curl_multi_init, todo!()) with a mocked subclass/package"] +#[ignore = "FileDownloader::process_url is pub(crate); not reachable from the integration test crate"] fn test_process_url2() { todo!() } #[test] -#[ignore = "constructs an ArchiveDownloader (HttpDownloader reaches curl_multi_init, todo!()) with a mocked subclass/package"] +#[ignore = "FileDownloader::process_url is pub(crate); not reachable from the integration test crate"] fn test_process_url3() { todo!() } #[test] -#[ignore = "constructs an ArchiveDownloader (HttpDownloader reaches curl_multi_init, todo!()) with a mocked subclass/package"] +#[ignore = "FileDownloader::process_url is pub(crate); not reachable from the integration test crate"] fn test_process_url_rewrite_dist() { todo!() } #[test] -#[ignore = "constructs an ArchiveDownloader (HttpDownloader reaches curl_multi_init, todo!()) with a mocked subclass/package"] +#[ignore = "FileDownloader::process_url is pub(crate); not reachable from the integration test crate"] fn test_process_url_rewrite_bitbucket_dist() { todo!() } diff --git a/crates/shirabe/tests/downloader/download_manager_test.rs b/crates/shirabe/tests/downloader/download_manager_test.rs index f9c44f4..b7fa976 100644 --- a/crates/shirabe/tests/downloader/download_manager_test.rs +++ b/crates/shirabe/tests/downloader/download_manager_test.rs @@ -7,218 +7,218 @@ fn set_up() { // These mock IO and individual downloaders to drive DownloadManager's selection/download/ // update/remove logic; mocking is not available here. +#[ignore = "requires PHPUnit mock of DownloaderInterface (createDownloaderMock)"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_set_get_downloader() { set_up(); todo!() } +#[ignore = "requires PHPUnit mock of PackageInterface (createPackageMock)"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_get_downloader_for_incorrectly_installed_package() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_get_downloader_for_correctly_installed_dist_package() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_get_downloader_for_incorrectly_installed_dist_package() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_get_downloader_for_correctly_installed_source_package() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloader"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_get_downloader_for_incorrectly_installed_source_package() { set_up(); todo!() } +#[ignore = "requires PHPUnit mock of PackageInterface (createPackageMock)"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_get_downloader_for_metapackage() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_full_package_download() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_full_package_download_failover() { set_up(); todo!() } +#[ignore = "requires PHPUnit mock of PackageInterface (createPackageMock)"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_bad_package_download() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_dist_only_package_download() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_source_only_package_download() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_metapackage_package_download() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_full_package_download_with_source_preferred() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_dist_only_package_download_with_source_preferred() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_source_only_package_download_with_source_preferred() { set_up(); todo!() } +#[ignore = "requires PHPUnit mock of PackageInterface (createPackageMock)"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_bad_package_download_with_source_preferred() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks of PackageInterface and DownloaderInterface"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_update_dist_with_equal_types() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks of PackageInterface and DownloaderInterface"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_update_dist_with_not_equal_types() { set_up(); todo!() } +#[ignore = "requires PHPUnit mock of PackageInterface and ReflectionMethod for private getAvailableSources"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_get_available_sources_update_sticks_to_same_source() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_update_metapackage() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_remove() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_metapackage_remove() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_without_preference_dev() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_without_preference_no_dev() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_without_match_dev() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_without_match_no_dev() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_with_match_auto_dev() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_with_match_auto_no_dev() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_with_match_source() { set_up(); todo!() } +#[ignore = "requires PHPUnit mocks and partial mock of DownloadManager::getDownloaderForPackage"] #[test] -#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] fn test_install_preference_with_match_dist() { set_up(); todo!() diff --git a/crates/shirabe/tests/downloader/file_downloader_test.rs b/crates/shirabe/tests/downloader/file_downloader_test.rs index 9e376be..b99dd93 100644 --- a/crates/shirabe/tests/downloader/file_downloader_test.rs +++ b/crates/shirabe/tests/downloader/file_downloader_test.rs @@ -8,63 +8,63 @@ fn set_up() { // These construct a FileDownloader with a mocked IO/HttpDownloader (curl_multi_init todo!()) // and a mocked Cache/Package to drive download/checksum behaviour. #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mock of HttpDownloader::addCopy (getDownloader helper); no mocking framework and real HttpDownloader reaches curl_multi_init todo!()"] fn test_download_for_package_without_dist_reference() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mock of HttpDownloader::addCopy (getDownloader helper); no mocking framework and real HttpDownloader reaches curl_multi_init todo!()"] fn test_download_to_existing_file() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mock of HttpDownloader::addCopy (getDownloader helper) and ReflectionMethod on private getFileName; no mocking/reflection framework"] fn test_get_file_name() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mock of HttpDownloader::addCopy and IOInterface::write callback; no mocking framework and real HttpDownloader reaches curl_multi_init todo!()"] fn test_download_but_file_is_unsaved() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mocks of Cache::copyTo/copyFrom and HttpDownloader::addCopy with assertion callbacks; no mocking framework"] fn test_download_with_custom_processed_url() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mocks of Cache::copyTo/copyFrom and HttpDownloader::addCopy with assertion callbacks; no mocking framework"] fn test_download_with_custom_cache_key() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mock of Cache::gcIsNecessary/gc with expectation tracking; no mocking framework"] fn test_cache_garbage_collection_is_called() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mock of Filesystem and HttpDownloader::addCopy plus ReflectionMethod on private getFileName; no mocking/reflection framework"] fn test_download_file_with_invalid_checksum() { set_up(); todo!() } #[test] -#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +#[ignore = "requires PHPUnit mocks of Filesystem::removeDirectoryAsync/normalizePath, HttpDownloader::addCopy, getIOMock expectations and ReflectionMethod on private getFileName; no mocking/reflection framework"] fn test_downgrade_shows_appropriate_message() { set_up(); todo!() diff --git a/crates/shirabe/tests/downloader/fossil_downloader_test.rs b/crates/shirabe/tests/downloader/fossil_downloader_test.rs index 9c9dbe4..0c45d2c 100644 --- a/crates/shirabe/tests/downloader/fossil_downloader_test.rs +++ b/crates/shirabe/tests/downloader/fossil_downloader_test.rs @@ -35,7 +35,7 @@ impl Drop for TearDown { // curl_multi_init (todo!()), and ProcessExecutor mocking is not available. #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock and PHPUnit mocks of IOInterface/PackageInterface/Filesystem for getDownloaderMock; not available"] fn test_install_for_package_without_source_reference() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -44,7 +44,7 @@ fn test_install_for_package_without_source_reference() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock with expects() command-sequence assertions and PHPUnit PackageInterface mock; not available"] fn test_install() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -53,7 +53,7 @@ fn test_install() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock and PHPUnit mocks of IOInterface/PackageInterface/Filesystem for getDownloaderMock; not available"] fn test_updatefor_package_without_source_reference() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -62,7 +62,7 @@ fn test_updatefor_package_without_source_reference() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock with expects() command-sequence assertions and PHPUnit PackageInterface mock; not available"] fn test_update() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -71,7 +71,7 @@ fn test_update() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock and a PHPUnit Filesystem mock asserting removeDirectoryAsync; not available"] fn test_remove() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -80,7 +80,7 @@ fn test_remove() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock and PHPUnit mocks of IOInterface/Filesystem for getDownloaderMock; not available"] fn test_get_installation_source() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); diff --git a/crates/shirabe/tests/downloader/git_downloader_test.rs b/crates/shirabe/tests/downloader/git_downloader_test.rs index c820254..69b0a6c 100644 --- a/crates/shirabe/tests/downloader/git_downloader_test.rs +++ b/crates/shirabe/tests/downloader/git_downloader_test.rs @@ -44,8 +44,8 @@ impl Drop for TearDown { // These construct a GitDownloader with a mocked IO/Config and a mocked ProcessExecutor to // feed git command output; mocking is not available, and a real HttpDownloader reaches // curl_multi_init (todo!()). +#[ignore = "requires getProcessExecutorMock/getIOMock and getMockBuilder PackageInterface mock; no ProcessExecutorMock/IOMock mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_download_for_package_without_source_reference() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -53,8 +53,8 @@ fn test_download_for_package_without_source_reference() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_download() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -62,8 +62,8 @@ fn test_download() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and initGitVersion reflection on Git::version static cache; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_download_with_cache() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -71,8 +71,8 @@ fn test_download_with_cache() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_download_uses_various_protocols_and_sets_push_url_for_github() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -80,8 +80,8 @@ fn test_download_uses_various_protocols_and_sets_push_url_for_github() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and pushUrlProvider dataProvider; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_download_and_set_push_url_use_custom_various_protocols_for_github() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -89,8 +89,8 @@ fn test_download_and_set_push_url_use_custom_various_protocols_for_github() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_download_throws_runtime_exception_if_git_command_fails() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -98,8 +98,8 @@ fn test_download_throws_runtime_exception_if_git_command_fails() { todo!() } +#[ignore = "requires getProcessExecutorMock/getDownloaderMock and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_updatefor_package_without_source_reference() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -107,8 +107,8 @@ fn test_updatefor_package_without_source_reference() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_update() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -116,8 +116,8 @@ fn test_update() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_update_with_new_repo_url() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -125,8 +125,8 @@ fn test_update_with_new_repo_url() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_update_throws_runtime_exception_if_git_command_fails() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -134,8 +134,8 @@ fn test_update_throws_runtime_exception_if_git_command_fails() { todo!() } +#[ignore = "requires getProcessExecutorMock with expects() command expectations and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_update_doesnt_throws_runtime_exception_if_git_command_fails_at_first_but_is_able_to_recover() { let working_dir = set_up(); @@ -144,8 +144,8 @@ fn test_update_doesnt_throws_runtime_exception_if_git_command_fails_at_first_but todo!() } +#[ignore = "requires getIOMock with expects() output expectations, getProcessExecutorMock and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_downgrade_shows_appropriate_message() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -153,8 +153,8 @@ fn test_downgrade_shows_appropriate_message() { todo!() } +#[ignore = "requires getIOMock with expects() output expectations, getProcessExecutorMock and getMockBuilder PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_not_using_downgrading_with_references() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -162,8 +162,8 @@ fn test_not_using_downgrading_with_references() { todo!() } +#[ignore = "requires getProcessExecutorMock, getMockBuilder Filesystem mock with removeDirectoryAsync expectation and PackageInterface mock; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_remove() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -171,8 +171,8 @@ fn test_remove() { todo!() } +#[ignore = "requires getDownloaderMock which mocks IOInterface/Filesystem via getMockBuilder; no mocking infrastructure exists"] #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] fn test_get_installation_source() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); diff --git a/crates/shirabe/tests/downloader/hg_downloader_test.rs b/crates/shirabe/tests/downloader/hg_downloader_test.rs index 0bbcdf7..67a13cb 100644 --- a/crates/shirabe/tests/downloader/hg_downloader_test.rs +++ b/crates/shirabe/tests/downloader/hg_downloader_test.rs @@ -35,7 +35,7 @@ impl Drop for TearDown { // curl_multi_init (todo!()), and ProcessExecutor mocking is not available. #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs PHPUnit mocks of IOInterface/Config/Filesystem/PackageInterface for getDownloaderMock; not available"] fn test_download_for_package_without_source_reference() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -44,7 +44,7 @@ fn test_download_for_package_without_source_reference() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock with expects() command-sequence assertions and PHPUnit PackageInterface mock; not available"] fn test_download() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -53,7 +53,7 @@ fn test_download() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs PHPUnit mocks of IOInterface/Config/Filesystem/PackageInterface for getDownloaderMock; not available"] fn test_updatefor_package_without_source_reference() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -62,7 +62,7 @@ fn test_updatefor_package_without_source_reference() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock with expects() command-sequence assertions and PHPUnit PackageInterface mock; not available"] fn test_update() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -71,7 +71,7 @@ fn test_update() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs ProcessExecutorMock and PHPUnit Filesystem mock with removeDirectoryAsync expectation; not available"] fn test_remove() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); @@ -80,7 +80,7 @@ fn test_remove() { } #[test] -#[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] +#[ignore = "needs PHPUnit mocks of IOInterface/Config/Filesystem for getDownloaderMock; not available"] fn test_get_installation_source() { let working_dir = set_up(); let _tear_down = TearDown::new(working_dir.path().to_path_buf()); diff --git a/crates/shirabe/tests/downloader/perforce_downloader_test.rs b/crates/shirabe/tests/downloader/perforce_downloader_test.rs index e0f7637..63f1de4 100644 --- a/crates/shirabe/tests/downloader/perforce_downloader_test.rs +++ b/crates/shirabe/tests/downloader/perforce_downloader_test.rs @@ -15,29 +15,29 @@ fn set_up() -> TempDir { // These mock Perforce, the repository config and a Package to drive PerforceDownloader's // initialization and install paths; mocking is not available here. +#[ignore = "requires PHPUnit getMockBuilder mocks of IOInterface/PackageInterface/VcsRepository and ProcessExecutorMock via unported set_up()"] #[test] -#[ignore = "mocks Perforce/repository/Package; mocking is not available"] fn test_init_perforce_instantiates_a_new_perforce_object() { let _test_path = set_up(); todo!() } +#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Util\\Perforce and expects()->never() verification, unavailable in the Rust port"] #[test] -#[ignore = "mocks Perforce/repository/Package; mocking is not available"] fn test_init_perforce_does_nothing_if_perforce_already_set() { let _test_path = set_up(); todo!() } +#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Util\\Perforce with expects()->once()->method() expectation verification, unavailable in the Rust port"] #[test] -#[ignore = "mocks Perforce/repository/Package; mocking is not available"] fn test_do_install_with_tag() { let _test_path = set_up(); todo!() } +#[ignore = "requires PHPUnit getMockBuilder mock of Composer\\Util\\Perforce with expects()->once()->method() expectation verification, unavailable in the Rust port"] #[test] -#[ignore = "mocks Perforce/repository/Package; mocking is not available"] fn test_do_install_with_no_tag() { let _test_path = set_up(); todo!() diff --git a/crates/shirabe/tests/downloader/xz_downloader_test.rs b/crates/shirabe/tests/downloader/xz_downloader_test.rs index d01779b..973a726 100644 --- a/crates/shirabe/tests/downloader/xz_downloader_test.rs +++ b/crates/shirabe/tests/downloader/xz_downloader_test.rs @@ -1,9 +1,37 @@ //! ref: composer/tests/Composer/Test/Downloader/XzDownloaderTest.php +use std::cell::RefCell; +use std::rc::Rc; + +use indexmap::IndexMap; +use shirabe::config::Config; +use shirabe::downloader::DownloaderInterface; +use shirabe::downloader::xz_downloader::XzDownloader; +use shirabe::io::IOInterface; +use shirabe::io::null_io::NullIO; +use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; +use shirabe::util::HttpDownloader; use shirabe::util::Platform; +use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::Filesystem; +use shirabe::util::r#loop::Loop; +use shirabe_php_shim::PhpMixed; +use shirabe_semver::version_parser::VersionParser; use tempfile::TempDir; +/// ref: TestCase::getPackage (default class CompletePackage) +fn get_package(name: &str, version: &str) -> PackageInterfaceHandle { + let norm_version = VersionParser.normalize(version, None).unwrap(); + CompletePackageHandle::new(name.to_string(), norm_version, version.to_string()).into() +} + +fn run<F: std::future::Future>(future: F) -> F::Output { + tokio::runtime::Builder::new_current_thread() + .build() + .unwrap() + .block_on(future) +} + fn set_up() -> TempDir { if Platform::is_windows() { // markTestSkipped('Skip test on Windows') @@ -40,11 +68,67 @@ impl Drop for TearDown { } } +/// ref: TestCase::getConfig +fn get_config(config_options: IndexMap<String, PhpMixed>, use_environment: bool) -> Config { + let mut config = Config::new(use_environment, None); + let mut merged: IndexMap<String, PhpMixed> = IndexMap::new(); + merged.insert("config".to_string(), PhpMixed::Array(config_options)); + config.merge(&merged, "test"); + config +} + +#[ignore] #[test] -#[ignore = "needs a real HttpDownloader/Loop and an XzDownloader download cycle; HttpDownloader construction reaches curl_multi_init (todo!()) in the php-shim"] fn test_error_messages() { let test_dir = set_up(); let _tear_down = TearDown::new(test_dir.path().to_path_buf()); - let _ = &test_dir; - todo!() + let test_dir = test_dir.path().to_path_buf(); + + let package = get_package("dummy/pkg", "1.0.0"); + let dist_url = format!("file://{}", file!()); + package.set_dist_url(Some(dist_url)); + + let io: Rc<RefCell<dyn IOInterface>> = Rc::new(RefCell::new(NullIO::new())); + let mut config_options: IndexMap<String, PhpMixed> = IndexMap::new(); + config_options.insert( + "vendor-dir".to_string(), + PhpMixed::String(test_dir.to_string_lossy().into_owned()), + ); + let config = Rc::new(RefCell::new(get_config(config_options, false))); + let http_downloader = Rc::new(RefCell::new(HttpDownloader::new( + io.clone(), + config.clone(), + IndexMap::new(), + false, + ))); + let filesystem = Rc::new(RefCell::new(Filesystem::new(None))); + let process = Rc::new(RefCell::new(ProcessExecutor::new(Some(io.clone())))); + let mut downloader = XzDownloader::new( + io, + config, + http_downloader.clone(), + None, + None, + filesystem, + process, + ); + + let install_path = test_dir.join("install-path"); + let install_path = install_path.to_string_lossy().into_owned(); + + let mut loop_ = Loop::new(http_downloader, None); + let promise = Box::pin(async { + downloader + .download3(package.clone(), &install_path, None) + .await + .map(|_| ()) + }); + run(loop_.wait(vec![promise], None)).unwrap(); + let result = run(downloader.install2(package, &install_path)); + + // Download of invalid tarball should throw an exception. + let e = result.expect_err("Download of invalid tarball should throw an exception"); + let re = + regex::Regex::new("(?i)(File format not recognized|Unrecognized archive format)").unwrap(); + assert!(re.is_match(&e.to_string())); } diff --git a/crates/shirabe/tests/downloader/zip_downloader_test.rs b/crates/shirabe/tests/downloader/zip_downloader_test.rs index c22afa1..0bffa89 100644 --- a/crates/shirabe/tests/downloader/zip_downloader_test.rs +++ b/crates/shirabe/tests/downloader/zip_downloader_test.rs @@ -47,8 +47,8 @@ impl Drop for TearDown { // These construct a ZipDownloader with a mocked IO/HttpDownloader/ProcessExecutor and rely // on ZipArchive extraction (todo!() in the php-shim) plus mocked unzip behaviour. +#[ignore = "requires PHPUnit mocks of IOInterface/Config/PackageInterface; set_up() is todo!() and real HttpDownloader reaches curl_multi_init todo!(); no mocking framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_error_messages() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); @@ -56,8 +56,8 @@ fn test_error_messages() { todo!() } +#[ignore = "requires setPrivateProperty reflection on hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and a getMockBuilder('ZipArchive') mock; no mocking/reflection framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_zip_archive_only_failed() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); @@ -65,8 +65,8 @@ fn test_zip_archive_only_failed() { todo!() } +#[ignore = "requires setPrivateProperty reflection on hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and a getMockBuilder('ZipArchive') mock throwing ErrorException; no mocking/reflection framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_zip_archive_extract_only_failed() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); @@ -74,8 +74,8 @@ fn test_zip_archive_extract_only_failed() { todo!() } +#[ignore = "requires setPrivateProperty reflection on hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and a getMockBuilder('ZipArchive') mock; no mocking/reflection framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_zip_archive_only_good() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); @@ -83,8 +83,8 @@ fn test_zip_archive_only_good() { todo!() } +#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/unzipCommands, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor::executeAsync; no mocking/reflection framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_system_unzip_only_failed() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); @@ -92,8 +92,8 @@ fn test_system_unzip_only_failed() { todo!() } +#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/unzipCommands, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor::executeAsync; no mocking/reflection framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_system_unzip_only_good() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); @@ -101,8 +101,8 @@ fn test_system_unzip_only_good() { todo!() } +#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor/ZipArchive; no mocking/reflection framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_non_windows_fallback_good() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); @@ -110,8 +110,8 @@ fn test_non_windows_fallback_good() { todo!() } +#[ignore = "requires setPrivateProperty reflection on isWindows/hasZipArchive/zipArchiveObject, a MockedZipDownloader subclass, and getMockBuilder mocks of Process/ProcessExecutor/ZipArchive; no mocking/reflection framework"] #[test] -#[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] fn test_non_windows_fallback_failed() { let set_up = set_up(); let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); |
