diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 00:51:53 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 00:51:53 +0900 |
| commit | c396d54f0302658304aa924a85b470f02d348182 (patch) | |
| tree | 08d3df986e3fe84c13450c328200b3bef7b6cf5d /crates/shirabe/tests/util/forgejo_url_test.rs | |
| parent | 53f027302ebcb91f6fb9b177f5e7e9e2d00c5089 (diff) | |
| download | php-shirabe-c396d54f0302658304aa924a85b470f02d348182.tar.gz php-shirabe-c396d54f0302658304aa924a85b470f02d348182.tar.zst php-shirabe-c396d54f0302658304aa924a85b470f02d348182.zip | |
test: port ForgejoUrl, Silencer, PlatformRequirementFilterFactory tests
Factory's instance-creation tests pass. ForgejoUrl (undelimited regex panic),
Silencer (trigger_error/microtime todo!()), and the factory's unknown-type
case (get_debug_type todo!()) are marked #[ignore].
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/util/forgejo_url_test.rs')
| -rw-r--r-- | crates/shirabe/tests/util/forgejo_url_test.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/crates/shirabe/tests/util/forgejo_url_test.rs b/crates/shirabe/tests/util/forgejo_url_test.rs index 970578e..17dae04 100644 --- a/crates/shirabe/tests/util/forgejo_url_test.rs +++ b/crates/shirabe/tests/util/forgejo_url_test.rs @@ -1 +1,43 @@ //! ref: composer/tests/Composer/Test/Util/ForgejoUrlTest.php + +use shirabe::util::forgejo_url::ForgejoUrl; + +#[test] +#[ignore = "Preg::match panics: ForgejoUrl::URL_REGEX is an undelimited pattern"] +fn test_create() { + for repo_url in create_provider() { + let forgejo_url = ForgejoUrl::try_from(Some(repo_url)); + + assert!(forgejo_url.is_some()); + let forgejo_url = forgejo_url.unwrap(); + assert_eq!("codeberg.org", forgejo_url.origin_url); + assert_eq!("acme", forgejo_url.owner); + assert_eq!("repo", forgejo_url.repository); + assert_eq!( + "https://codeberg.org/api/v1/repos/acme/repo", + forgejo_url.api_url + ); + } +} + +fn create_provider() -> Vec<&'static str> { + vec![ + "git@codeberg.org:acme/repo.git", + "https://codeberg.org/acme/repo", + "https://codeberg.org/acme/repo.git", + ] +} + +#[test] +#[ignore = "Preg::match panics: ForgejoUrl::URL_REGEX is an undelimited pattern"] +fn test_create_invalid() { + assert!(ForgejoUrl::create("https://example.org").is_err()); +} + +#[test] +#[ignore = "Preg::match panics: ForgejoUrl::URL_REGEX is an undelimited pattern"] +fn test_generate_ssh_url() { + let forgejo_url = ForgejoUrl::create("git@codeberg.org:acme/repo.git").unwrap(); + + assert_eq!("git@codeberg.org:acme/repo.git", forgejo_url.generate_ssh_url()); +} |
