aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/tests')
-rw-r--r--crates/shirabe/tests/downloader/download_manager_test.rs8
-rw-r--r--crates/shirabe/tests/downloader/file_downloader_test.rs9
-rw-r--r--crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs7
-rw-r--r--crates/shirabe/tests/json/composer_schema_test.rs3
-rw-r--r--crates/shirabe/tests/json/json_file_test.rs23
-rw-r--r--crates/shirabe/tests/package/archiver/archive_manager_test.rs6
-rw-r--r--crates/shirabe/tests/package/loader/validating_array_loader_test.rs3
-rw-r--r--crates/shirabe/tests/package/locker_test.rs5
-rw-r--r--crates/shirabe/tests/plugin/plugin_installer_test.rs4
-rw-r--r--crates/shirabe/tests/repository/filesystem_repository_test.rs4
-rw-r--r--crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs7
-rw-r--r--crates/shirabe/tests/repository/vcs/git_driver_test.rs5
-rw-r--r--crates/shirabe/tests/repository/vcs/hg_driver_test.rs5
-rw-r--r--crates/shirabe/tests/repository/vcs/svn_driver_test.rs5
-rw-r--r--crates/shirabe/tests/util/auth_helper_test.rs5
-rw-r--r--crates/shirabe/tests/util/git_test.rs3
-rw-r--r--crates/shirabe/tests/util/http_downloader_test.rs3
-rw-r--r--crates/shirabe/tests/util/silencer_test.rs6
18 files changed, 55 insertions, 56 deletions
diff --git a/crates/shirabe/tests/downloader/download_manager_test.rs b/crates/shirabe/tests/downloader/download_manager_test.rs
index 9d12bad6..dd894565 100644
--- a/crates/shirabe/tests/downloader/download_manager_test.rs
+++ b/crates/shirabe/tests/downloader/download_manager_test.rs
@@ -253,13 +253,7 @@ fn test_full_package_download_failover() {
.expect_download()
.times(1)
.withf(|_pkg, path, _prev, _output| path == "target_dir")
- .returning(|_, _, _, _| {
- Err(RuntimeException {
- message: "Foo".to_string(),
- code: 0,
- }
- .into())
- });
+ .returning(|_, _, _, _| Err(RuntimeException::new("Foo".to_string()).into()));
let mut downloader_success = downloader_mock("source");
downloader_success
diff --git a/crates/shirabe/tests/downloader/file_downloader_test.rs b/crates/shirabe/tests/downloader/file_downloader_test.rs
index 469bf473..eac4e45e 100644
--- a/crates/shirabe/tests/downloader/file_downloader_test.rs
+++ b/crates/shirabe/tests/downloader/file_downloader_test.rs
@@ -17,6 +17,7 @@ use shirabe::util::HttpDownloader;
use shirabe::util::filesystem::{Filesystem, FilesystemMock};
use shirabe::util::http_downloader::HttpDownloaderMockHandler;
use shirabe::util::r#loop::Loop;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, UnexpectedValueException,
};
@@ -84,7 +85,7 @@ fn test_download_for_package_without_dist_reference() {
let e = result.expect_err("expected InvalidArgumentException");
assert!(
- e.downcast_ref::<InvalidArgumentException>().is_some(),
+ e.is_instanceof::<InvalidArgumentException>(),
"expected InvalidArgumentException, got: {e}"
);
}
@@ -107,7 +108,7 @@ fn test_download_to_existing_file() {
let e = result.expect_err("download to an existing file was expected to throw");
assert!(
- e.downcast_ref::<RuntimeException>().is_some(),
+ e.is_instanceof::<RuntimeException>(),
"expected RuntimeException, got: {e}"
);
assert!(
@@ -167,7 +168,7 @@ fn test_download_but_file_is_unsaved() {
let e = result.expect_err("download was expected to throw");
assert!(
- e.downcast_ref::<UnexpectedValueException>().is_some(),
+ e.is_instanceof::<UnexpectedValueException>(),
"expected UnexpectedValueException, got: {e}"
);
assert!(
@@ -294,7 +295,7 @@ fn test_download_file_with_invalid_checksum() {
let e = result.expect_err("download was expected to throw");
assert!(
- e.downcast_ref::<UnexpectedValueException>().is_some(),
+ e.is_instanceof::<UnexpectedValueException>(),
"expected UnexpectedValueException, got: {e}"
);
assert!(
diff --git a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
index af8a33db..817a6954 100644
--- a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
+++ b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
@@ -27,6 +27,7 @@ use shirabe::util::platform::Platform;
use shirabe::util::process_executor::{MockHandler, ProcessExecutor};
use shirabe_class_map_generator::class_map::ClassMap;
use shirabe_external_packages::symfony::console::output::output_interface;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PHP_EOL, PhpMixed};
fn tear_down() {
@@ -286,8 +287,7 @@ fn test_dispatcher_detect_infinite_recursion() {
let result = dispatcher.dispatch(Some("root"), Some(&mut event));
let err = result.expect_err("infinite recursion must raise a RuntimeException");
assert!(
- err.downcast_ref::<shirabe_php_shim::RuntimeException>()
- .is_some(),
+ err.is_instanceof::<shirabe_php_shim::RuntimeException>(),
"expected RuntimeException, got: {err:?}"
);
}
@@ -392,8 +392,7 @@ fn test_listener_exceptions_are_caught() {
let e = result.expect_err("expected RuntimeException");
assert!(
- e.downcast_ref::<shirabe_php_shim::RuntimeException>()
- .is_some(),
+ e.is_instanceof::<shirabe_php_shim::RuntimeException>(),
"got: {e:?}"
);
}
diff --git a/crates/shirabe/tests/json/composer_schema_test.rs b/crates/shirabe/tests/json/composer_schema_test.rs
index 9cbea150..f2a5da44 100644
--- a/crates/shirabe/tests/json/composer_schema_test.rs
+++ b/crates/shirabe/tests/json/composer_schema_test.rs
@@ -9,6 +9,7 @@
//! which property) is identical to upstream.
use shirabe::json::{JsonFile, JsonValidationException};
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::json_decode;
const NAME_PATTERN: &str = r#"^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$"#;
@@ -22,7 +23,7 @@ fn check(json: &str) -> Vec<String> {
match JsonFile::validate_json_schema("test", &data, JsonFile::LAX_SCHEMA, None) {
Ok(_) => Vec::new(),
Err(e) => e
- .downcast_ref::<JsonValidationException>()
+ .catch::<JsonValidationException>()
.unwrap()
.get_errors()
.clone(),
diff --git a/crates/shirabe/tests/json/json_file_test.rs b/crates/shirabe/tests/json/json_file_test.rs
index 49ac1605..a20e7234 100644
--- a/crates/shirabe/tests/json/json_file_test.rs
+++ b/crates/shirabe/tests/json/json_file_test.rs
@@ -3,6 +3,7 @@
use indexmap::IndexMap;
use shirabe::json::{JsonEncodeOptions, JsonFile, JsonValidationException};
use shirabe_external_packages::seld::json_lint::ParsingException;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::PhpMixed;
/// ref: JsonFileTest::expectParseException
@@ -269,14 +270,14 @@ fn test_schema_validation_error() {
let err = json
.validate_schema(JsonFile::STRICT_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
assert!(e.get_errors().contains(&expected_error));
let err = json
.validate_schema(JsonFile::LAX_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
assert!(e.get_errors().contains(&expected_error));
}
@@ -298,7 +299,7 @@ fn test_schema_validation_lax_additional_properties() {
let err = json
.validate_schema(JsonFile::STRICT_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(
format!("\"{}\" does not match the expected JSON schema", file),
e.get_message()
@@ -327,7 +328,7 @@ fn test_schema_validation_lax_required() {
let err = json
.validate_schema(JsonFile::STRICT_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
let errors = e.get_errors();
assert!(errors.contains(&"name : \"name\" is a required property".to_string()));
@@ -338,7 +339,7 @@ fn test_schema_validation_lax_required() {
let err = json
.validate_schema(JsonFile::STRICT_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
assert_eq!(
&vec!["description : \"description\" is a required property".to_string()],
@@ -350,7 +351,7 @@ fn test_schema_validation_lax_required() {
let err = json
.validate_schema(JsonFile::STRICT_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
assert_eq!(
&vec!["name : \"name\" is a required property".to_string()],
@@ -362,7 +363,7 @@ fn test_schema_validation_lax_required() {
let err = json
.validate_schema(JsonFile::STRICT_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
let errors = e.get_errors();
assert!(errors.contains(&"name : \"name\" is a required property".to_string()));
@@ -373,7 +374,7 @@ fn test_schema_validation_lax_required() {
let err = json
.validate_schema(JsonFile::STRICT_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
let errors = e.get_errors();
assert!(errors.contains(&"name : \"name\" is a required property".to_string()));
@@ -444,7 +445,7 @@ fn test_auth_schema_validation_with_custom_data_source() {
let err = JsonFile::validate_json_schema("COMPOSER_AUTH", &json, JsonFile::AUTH_SCHEMA, None)
.unwrap_err();
- let e = err.downcast_ref::<JsonValidationException>().unwrap();
+ let e = err.catch::<JsonValidationException>().unwrap();
assert_eq!(expected_message, e.get_message());
assert_eq!(&vec![expected_error], e.get_errors());
}
@@ -519,7 +520,7 @@ fn test_composer_lock_file_merge_conflict_complex() {
std::fs::read_to_string(fixture_path("composer-lock-merge-conflict-complex.txt")).unwrap();
let err = JsonFile::parse_json(Some(&data), Some("/path/to/composer.lock")).unwrap_err();
- assert!(err.downcast_ref::<ParsingException>().is_some());
+ assert!(err.is_instanceof::<ParsingException>());
}
#[test]
@@ -531,7 +532,7 @@ fn test_composer_lock_file_merge_conflict_complex_crlf() {
.unwrap();
let err = JsonFile::parse_json(Some(&data), Some("/path/to/composer.lock")).unwrap_err();
- assert!(err.downcast_ref::<ParsingException>().is_some());
+ assert!(err.is_instanceof::<ParsingException>());
}
#[test]
diff --git a/crates/shirabe/tests/package/archiver/archive_manager_test.rs b/crates/shirabe/tests/package/archiver/archive_manager_test.rs
index a7235bf9..84feb5bc 100644
--- a/crates/shirabe/tests/package/archiver/archive_manager_test.rs
+++ b/crates/shirabe/tests/package/archiver/archive_manager_test.rs
@@ -13,6 +13,7 @@ use shirabe::util::ProcessExecutor;
use shirabe::util::http_downloader::HttpDownloader;
use shirabe::util::r#loop::Loop;
use shirabe_external_packages::symfony::process::Process;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
PhpMixed, file_exists, file_put_contents, realpath, sys_get_temp_dir, unlink,
};
@@ -159,10 +160,7 @@ fn test_unknown_format() {
);
let err = result.expect_err("expected RuntimeException for unknown format");
- assert!(
- err.downcast_ref::<shirabe_php_shim::RuntimeException>()
- .is_some()
- );
+ assert!(err.is_instanceof::<shirabe_php_shim::RuntimeException>());
}
// ref: ArchiveManagerTest::testArchiveTar / testArchiveCustomFileName.
diff --git a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs
index 07f3e4a6..1b1ed448 100644
--- a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs
+++ b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs
@@ -4,6 +4,7 @@ use crate::test_case;
use indexmap::IndexMap;
use shirabe::package::handle::PackageInterfaceHandle;
use shirabe::package::loader::{InvalidPackageException, LoaderInterface, ValidatingArrayLoader};
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::PhpMixed;
fn s(v: &str) -> PhpMixed {
@@ -792,7 +793,7 @@ fn test_load_failure_throws_exception() {
Ok(_) => panic!("Expected exception to be thrown"),
Err(e) => {
let exception = e
- .downcast_ref::<InvalidPackageException>()
+ .catch::<InvalidPackageException>()
.expect("Expected InvalidPackageException");
let mut errors: Vec<String> = exception.get_errors().to_vec();
expected_errors.sort();
diff --git a/crates/shirabe/tests/package/locker_test.rs b/crates/shirabe/tests/package/locker_test.rs
index f1747166..4732d679 100644
--- a/crates/shirabe/tests/package/locker_test.rs
+++ b/crates/shirabe/tests/package/locker_test.rs
@@ -10,6 +10,7 @@ use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle};
use shirabe::plugin::plugin_interface;
use shirabe::repository::{FindPackageConstraint, RepositoryInterfaceHandle};
use shirabe::util::process_executor::ProcessExecutor;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{LogicException, PhpMixed, hash};
use tempfile::TempDir;
@@ -83,7 +84,7 @@ fn test_get_not_locked_packages() {
.get_locked_repository(false)
.expect_err("getLockedRepository should fail when no lock file exists");
assert!(
- err.downcast_ref::<LogicException>().is_some(),
+ err.is_instanceof::<LogicException>(),
"expected LogicException, got: {err}"
);
}
@@ -219,7 +220,7 @@ fn test_lock_bad_packages() {
)
.expect_err("setLockData should fail for a package with no version");
assert!(
- err.downcast_ref::<LogicException>().is_some(),
+ err.is_instanceof::<LogicException>(),
"expected LogicException, got: {err}"
);
}
diff --git a/crates/shirabe/tests/plugin/plugin_installer_test.rs b/crates/shirabe/tests/plugin/plugin_installer_test.rs
index 06cd2ce9..0c82a11a 100644
--- a/crates/shirabe/tests/plugin/plugin_installer_test.rs
+++ b/crates/shirabe/tests/plugin/plugin_installer_test.rs
@@ -31,6 +31,7 @@ use shirabe::util::r#loop::Loop;
use shirabe::util::process_executor::ProcessExecutor;
use shirabe_external_packages::symfony::console::output::output_interface::VERBOSITY_NORMAL;
use shirabe_external_packages::symfony::process::PhpExecutableFinder;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::PhpMixed;
use shirabe_semver::VersionParser;
use tempfile::TempDir;
@@ -859,8 +860,7 @@ fn test_querying_with_invalid_capability_class_name_throws() {
),
};
assert!(
- err.downcast_ref::<shirabe_php_shim::UnexpectedValueException>()
- .is_some(),
+ err.is_instanceof::<shirabe_php_shim::UnexpectedValueException>(),
"expected UnexpectedValueException for {invalid_implementation_class_name:?}, got: {err}"
);
// PHP: ->expects($this->once())->method('getCapabilities').
diff --git a/crates/shirabe/tests/repository/filesystem_repository_test.rs b/crates/shirabe/tests/repository/filesystem_repository_test.rs
index 3279f29e..a9ac91a0 100644
--- a/crates/shirabe/tests/repository/filesystem_repository_test.rs
+++ b/crates/shirabe/tests/repository/filesystem_repository_test.rs
@@ -13,6 +13,7 @@ use shirabe::package::{Link, PackageInterfaceHandle, RootAliasPackageHandle, Roo
use shirabe::repository::RepositoryInterface;
use shirabe::repository::filesystem_repository::FilesystemRepository;
use shirabe::util::filesystem::Filesystem;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::PhpMixed;
use shirabe_semver::VersionParser;
@@ -50,7 +51,6 @@ fn test_repository_read() {
assert_eq!(packages[0].get_type(), "vendor");
}
-#[ignore = "InvalidRepositoryException message building calls shirabe_php_shim::var::get_class_err(), which is still todo!()"]
#[test]
fn test_corrupted_repository_file() {
// PHP mocks read() to return the scalar string 'foo'; a real file containing the JSON string
@@ -63,7 +63,7 @@ fn test_corrupted_repository_file() {
let result = repository.get_packages();
let err = result.unwrap_err();
assert!(
- err.is::<shirabe::repository::InvalidRepositoryException>(),
+ err.is_instanceof::<shirabe::repository::InvalidRepositoryException>(),
"expected InvalidRepositoryException, got: {err}"
);
}
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 4d84bcf2..67e9c8a9 100644
--- a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs
@@ -10,6 +10,7 @@ use shirabe::repository::vcs::GitBitbucketDriver;
use shirabe::util::filesystem::Filesystem;
use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler};
use shirabe::util::process_executor::ProcessExecutor;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{InvalidArgumentException, PhpMixed, RuntimeException};
use tempfile::TempDir;
@@ -112,11 +113,11 @@ fn test_get_root_identifier_wrong_scm_type() {
let err = driver.get_root_identifier().unwrap_err();
let runtime = err
- .downcast_ref::<RuntimeException>()
+ .catch::<RuntimeException>()
.expect("expected RuntimeException");
assert_eq!(
"https://bitbucket.org/user/repo.git does not appear to be a git repository, use https://bitbucket.org/user/repo but remember that Bitbucket no longer supports the mercurial repositories. https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket",
- runtime.message
+ runtime.get_message()
);
}
@@ -250,7 +251,7 @@ fn test_initialize_invalid_repository_url() {
let result = get_driver("https://bitbucket.org/acme", io, config, http_downloader);
let err = result.unwrap_err();
assert!(
- err.downcast_ref::<InvalidArgumentException>().is_some(),
+ err.is_instanceof::<InvalidArgumentException>(),
"expected InvalidArgumentException, got: {err:?}"
);
}
diff --git a/crates/shirabe/tests/repository/vcs/git_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_driver_test.rs
index 7a85d4cc..8494c1ca 100644
--- a/crates/shirabe/tests/repository/vcs/git_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/git_driver_test.rs
@@ -12,6 +12,7 @@ use shirabe::util::filesystem::Filesystem;
use shirabe::util::http_downloader::HttpDownloaderMockHandler;
use shirabe::util::platform::Platform;
use shirabe::util::process_executor::MockHandler;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, RuntimeException};
use tempfile::TempDir;
@@ -293,7 +294,7 @@ fn test_file_get_content_invalid_identifier() {
assert_eq!(None, driver.get_file_content("file.txt", "h").unwrap());
let err = driver.get_file_content("file.txt", "-h").unwrap_err();
- assert!(err.downcast_ref::<RuntimeException>().is_some());
+ assert!(err.is_instanceof::<RuntimeException>());
}
#[test]
@@ -324,5 +325,5 @@ fn test_get_change_date_invalid_identifier() {
let mut driver = GitDriver::new(repo_config, io, config, http_downloader, process);
let err = driver.get_change_date("-n1 --format=%at HEAD").unwrap_err();
- assert!(err.downcast_ref::<RuntimeException>().is_some());
+ assert!(err.is_instanceof::<RuntimeException>());
}
diff --git a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs
index be36f412..4245e140 100644
--- a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs
@@ -11,6 +11,7 @@ use shirabe::repository::vcs::HgDriver;
use shirabe::util::filesystem::Filesystem;
use shirabe::util::http_downloader::HttpDownloaderMockHandler;
use shirabe::util::process_executor::MockHandler;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, RuntimeException};
use tempfile::TempDir;
@@ -141,7 +142,7 @@ fn test_file_get_content_invalid_identifier() {
assert_eq!(None, driver.get_file_content("file.txt", "h").unwrap());
let err = driver.get_file_content("file.txt", "-h").unwrap_err();
- assert!(err.downcast_ref::<RuntimeException>().is_some());
+ assert!(err.is_instanceof::<RuntimeException>());
}
#[test]
@@ -168,5 +169,5 @@ fn test_get_change_date_invalid_identifier() {
let driver = HgDriver::new(repo_config, io, config, http_downloader, process);
let err = driver.get_change_date("-r foo").unwrap_err();
- assert!(err.downcast_ref::<RuntimeException>().is_some());
+ assert!(err.is_instanceof::<RuntimeException>());
}
diff --git a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
index 6a74063d..bc45b082 100644
--- a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs
@@ -11,6 +11,7 @@ use shirabe::repository::vcs::SvnDriver;
use shirabe::util::filesystem::Filesystem;
use shirabe::util::http_downloader::HttpDownloaderMockHandler;
use shirabe::util::process_executor::MockHandler;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, RuntimeException};
use tempfile::TempDir;
@@ -130,10 +131,10 @@ fn test_wrong_credentials_in_url() {
let mut svn = SvnDriver::new(repo_config, console, config, http_downloader, process);
let err = svn.initialize().unwrap_err();
let runtime = err
- .downcast_ref::<RuntimeException>()
+ .catch::<RuntimeException>()
.expect("expected RuntimeException");
assert_eq!(
"Repository https://till:secret@corp.svn.local/repo could not be processed, wrong credentials provided (svn: OPTIONS of 'https://corp.svn.local/repo': authorization failed: Could not authenticate to server: rejected Basic challenge (https://corp.svn.local/))",
- runtime.message
+ runtime.get_message()
);
}
diff --git a/crates/shirabe/tests/util/auth_helper_test.rs b/crates/shirabe/tests/util/auth_helper_test.rs
index ef5daaf7..6b376f97 100644
--- a/crates/shirabe/tests/util/auth_helper_test.rs
+++ b/crates/shirabe/tests/util/auth_helper_test.rs
@@ -7,6 +7,7 @@ use shirabe::config::ConfigSourceInterface;
use shirabe::io::IOInterface;
use shirabe::io::io_interface;
use shirabe::util::{AuthHelper, Bitbucket, StoreAuth};
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, base64_encode, json_encode};
// Mirrors AuthHelperTest::setUp: a DEBUG-verbosity IOMock plus a real Config, both
@@ -560,7 +561,7 @@ fn test_store_auth_with_prompt_invalid_answer() {
let err = auth_helper
.store_auth(origin, StoreAuth::Prompt)
.expect_err("expected a RuntimeException");
- assert!(err.downcast_ref::<RuntimeException>().is_some());
+ assert!(err.is_instanceof::<RuntimeException>());
// Mirrors PHP's `->with('Do you want to store credentials for '.$origin.' in '.
// $configSourceName.' ? [Yn] ', $this->anything(), null, 'y')` verification on askAndValidate.
@@ -639,7 +640,7 @@ fn test_prompt_auth_if_needed_git_lab_no_auth_change() {
);
let err = result.expect_err("expected a TransportException");
- assert!(err.downcast_ref::<TransportException>().is_some());
+ assert!(err.is_instanceof::<TransportException>());
assert_eq!(
vec![(
diff --git a/crates/shirabe/tests/util/git_test.rs b/crates/shirabe/tests/util/git_test.rs
index 907ec38a..dbc06137 100644
--- a/crates/shirabe/tests/util/git_test.rs
+++ b/crates/shirabe/tests/util/git_test.rs
@@ -11,6 +11,7 @@ use shirabe::util::filesystem::Filesystem;
use shirabe::util::git::Git;
use shirabe::util::http_downloader::HttpDownloaderMockHandler;
use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor};
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, RuntimeException};
// No-op ConfigSourceInterface, equivalent to PHPUnit's
@@ -195,7 +196,7 @@ fn test_run_command_private_git_hub_repository_not_initial_clone_not_interactive
);
let err = result.expect_err("expected a RuntimeException");
- assert!(err.downcast_ref::<RuntimeException>().is_some());
+ assert!(err.is_instanceof::<RuntimeException>());
}
// privateGithubWithCredentialsProvider helper.
diff --git a/crates/shirabe/tests/util/http_downloader_test.rs b/crates/shirabe/tests/util/http_downloader_test.rs
index b438dca9..f1883721 100644
--- a/crates/shirabe/tests/util/http_downloader_test.rs
+++ b/crates/shirabe/tests/util/http_downloader_test.rs
@@ -11,6 +11,7 @@ use shirabe::io::io_interface;
use shirabe::util::Platform;
use shirabe::util::http_downloader::HttpDownloader;
use shirabe_external_packages::symfony::console::output::output_interface::VERBOSITY_NORMAL;
+use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PHP_EOL, PhpMixed};
// PHP performs a live HTTP get to assert the URL's user:pass is captured via
@@ -49,7 +50,7 @@ fn test_capture_authentication_params_from_url() {
if let Err(e) = fs.get(
"https://user:pass@github.com/composer/composer/404",
IndexMap::new(),
- ) && let Some(te) = e.downcast_ref::<TransportException>()
+ ) && let Some(te) = e.catch::<TransportException>()
{
assert_ne!(200, te.get_code());
}
diff --git a/crates/shirabe/tests/util/silencer_test.rs b/crates/shirabe/tests/util/silencer_test.rs
index 000e7371..8c319400 100644
--- a/crates/shirabe/tests/util/silencer_test.rs
+++ b/crates/shirabe/tests/util/silencer_test.rs
@@ -35,11 +35,7 @@ fn test_silencer() {
fn test_silenced_exception() {
let verification = format!("{}", microtime());
let err = Silencer::call(|| -> anyhow::Result<()> {
- Err(RuntimeException {
- message: verification.clone(),
- code: 0,
- }
- .into())
+ Err(RuntimeException::new(verification.clone()).into())
})
.unwrap_err();
assert_eq!(verification, err.to_string());