From f0f5f084c883dc4f5b6e61603e82cd1c2092fd9d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 21 Jun 2026 13:11:49 +0900 Subject: test(tests): expand stub macros into plain test functions The per-file stub!/encode_stub!/etc. macros generated #[ignore]d test functions but obscured the individual test bodies. Expanding them inline removes the macro indirection so future ports can fill in each function directly. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../tests/downloader/download_manager_test.rs | 258 +++++++++++++++++---- .../tests/downloader/file_downloader_test.rs | 82 +++++-- .../tests/downloader/git_downloader_test.rs | 163 ++++++++++--- .../tests/downloader/zip_downloader_test.rs | 88 +++++-- 4 files changed, 482 insertions(+), 109 deletions(-) (limited to 'crates/shirabe/tests/downloader') diff --git a/crates/shirabe/tests/downloader/download_manager_test.rs b/crates/shirabe/tests/downloader/download_manager_test.rs index 4bb0f0b..f9c44f4 100644 --- a/crates/shirabe/tests/downloader/download_manager_test.rs +++ b/crates/shirabe/tests/downloader/download_manager_test.rs @@ -7,45 +7,219 @@ fn set_up() { // These mock IO and individual downloaders to drive DownloadManager's selection/download/ // update/remove logic; mocking is not available here. -macro_rules! stub { - ($name:ident) => { - #[test] - #[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] - fn $name() { - set_up(); - todo!() - } - }; -} - -stub!(test_set_get_downloader); -stub!(test_get_downloader_for_incorrectly_installed_package); -stub!(test_get_downloader_for_correctly_installed_dist_package); -stub!(test_get_downloader_for_incorrectly_installed_dist_package); -stub!(test_get_downloader_for_correctly_installed_source_package); -stub!(test_get_downloader_for_incorrectly_installed_source_package); -stub!(test_get_downloader_for_metapackage); -stub!(test_full_package_download); -stub!(test_full_package_download_failover); -stub!(test_bad_package_download); -stub!(test_dist_only_package_download); -stub!(test_source_only_package_download); -stub!(test_metapackage_package_download); -stub!(test_full_package_download_with_source_preferred); -stub!(test_dist_only_package_download_with_source_preferred); -stub!(test_source_only_package_download_with_source_preferred); -stub!(test_bad_package_download_with_source_preferred); -stub!(test_update_dist_with_equal_types); -stub!(test_update_dist_with_not_equal_types); -stub!(test_get_available_sources_update_sticks_to_same_source); -stub!(test_update_metapackage); -stub!(test_remove); -stub!(test_metapackage_remove); -stub!(test_install_preference_without_preference_dev); -stub!(test_install_preference_without_preference_no_dev); -stub!(test_install_preference_without_match_dev); -stub!(test_install_preference_without_match_no_dev); -stub!(test_install_preference_with_match_auto_dev); -stub!(test_install_preference_with_match_auto_no_dev); -stub!(test_install_preference_with_match_source); -stub!(test_install_preference_with_match_dist); +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_set_get_downloader() { + set_up(); + todo!() +} + +#[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!() +} + +#[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!() +} + +#[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!() +} + +#[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!() +} + +#[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!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_get_downloader_for_metapackage() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_full_package_download() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_full_package_download_failover() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_bad_package_download() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_dist_only_package_download() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_source_only_package_download() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_metapackage_package_download() { + set_up(); + todo!() +} + +#[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!() +} + +#[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!() +} + +#[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!() +} + +#[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!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_update_dist_with_equal_types() { + set_up(); + todo!() +} + +#[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!() +} + +#[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!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_update_metapackage() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_remove() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_metapackage_remove() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_install_preference_without_preference_dev() { + set_up(); + todo!() +} + +#[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!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_install_preference_without_match_dev() { + set_up(); + todo!() +} + +#[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!() +} + +#[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!() +} + +#[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!() +} + +#[test] +#[ignore = "mocks IO and individual downloaders to drive DownloadManager; mocking is not available"] +fn test_install_preference_with_match_source() { + set_up(); + todo!() +} + +#[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 6e123e1..9e376be 100644 --- a/crates/shirabe/tests/downloader/file_downloader_test.rs +++ b/crates/shirabe/tests/downloader/file_downloader_test.rs @@ -7,23 +7,65 @@ 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. -macro_rules! stub { - ($name:ident) => { - #[test] - #[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] - fn $name() { - set_up(); - todo!() - } - }; -} - -stub!(test_download_for_package_without_dist_reference); -stub!(test_download_to_existing_file); -stub!(test_get_file_name); -stub!(test_download_but_file_is_unsaved); -stub!(test_download_with_custom_processed_url); -stub!(test_download_with_custom_cache_key); -stub!(test_cache_garbage_collection_is_called); -stub!(test_download_file_with_invalid_checksum); -stub!(test_downgrade_shows_appropriate_message); +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_download_for_package_without_dist_reference() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_download_to_existing_file() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_get_file_name() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_download_but_file_is_unsaved() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_download_with_custom_processed_url() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_download_with_custom_cache_key() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_cache_garbage_collection_is_called() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_download_file_with_invalid_checksum() { + set_up(); + todo!() +} + +#[test] +#[ignore = "mocks IO/HttpDownloader (curl_multi_init todo!()) and Cache/Package"] +fn test_downgrade_shows_appropriate_message() { + set_up(); + todo!() +} diff --git a/crates/shirabe/tests/downloader/git_downloader_test.rs b/crates/shirabe/tests/downloader/git_downloader_test.rs index ad5e305..c820254 100644 --- a/crates/shirabe/tests/downloader/git_downloader_test.rs +++ b/crates/shirabe/tests/downloader/git_downloader_test.rs @@ -44,31 +44,138 @@ 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!()). -macro_rules! stub { - ($name:ident) => { - #[test] - #[ignore = "mocks ProcessExecutor/IO and needs an HttpDownloader (curl_multi_init todo!())"] - fn $name() { - let working_dir = set_up(); - let _tear_down = TearDown::new(working_dir.path().to_path_buf()); - let _ = &working_dir; - todo!() - } - }; -} - -stub!(test_download_for_package_without_source_reference); -stub!(test_download); -stub!(test_download_with_cache); -stub!(test_download_uses_various_protocols_and_sets_push_url_for_github); -stub!(test_download_and_set_push_url_use_custom_various_protocols_for_github); -stub!(test_download_throws_runtime_exception_if_git_command_fails); -stub!(test_updatefor_package_without_source_reference); -stub!(test_update); -stub!(test_update_with_new_repo_url); -stub!(test_update_throws_runtime_exception_if_git_command_fails); -stub!(test_update_doesnt_throws_runtime_exception_if_git_command_fails_at_first_but_is_able_to_recover); -stub!(test_downgrade_shows_appropriate_message); -stub!(test_not_using_downgrading_with_references); -stub!(test_remove); -stub!(test_get_installation_source); +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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(); + let _tear_down = TearDown::new(working_dir.path().to_path_buf()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} + +#[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()); + let _ = &working_dir; + todo!() +} diff --git a/crates/shirabe/tests/downloader/zip_downloader_test.rs b/crates/shirabe/tests/downloader/zip_downloader_test.rs index aa4646c..c22afa1 100644 --- a/crates/shirabe/tests/downloader/zip_downloader_test.rs +++ b/crates/shirabe/tests/downloader/zip_downloader_test.rs @@ -47,24 +47,74 @@ 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. -macro_rules! stub { - ($name:ident) => { - #[test] - #[ignore = "mocks IO/HttpDownloader/ProcessExecutor and uses ZipArchive (todo!())"] - fn $name() { - let set_up = set_up(); - let _tear_down = TearDown::new(set_up.test_dir.path().to_path_buf()); - let _ = (&set_up.test_dir, &set_up.filename); - todo!() - } - }; +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() +} + +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() } -stub!(test_error_messages); -stub!(test_zip_archive_only_failed); -stub!(test_zip_archive_extract_only_failed); -stub!(test_zip_archive_only_good); -stub!(test_system_unzip_only_failed); -stub!(test_system_unzip_only_good); -stub!(test_non_windows_fallback_good); -stub!(test_non_windows_fallback_failed); +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() +} + +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() +} + +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() +} + +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() +} + +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() +} + +#[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()); + let _ = (&set_up.test_dir, &set_up.filename); + todo!() +} -- cgit v1.3.1