diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-11 02:36:42 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-11 02:36:42 +0900 |
| commit | 4e99773a3d203e73b8bf6464490d05649a269fa7 (patch) | |
| tree | 7a6f1a7f773a14ea72dc2f9ff4124badd345833d /crates/mozart/src/commands/show.rs | |
| parent | 4df5f8491320e5795718cf0222e80fa27e57c8ad (diff) | |
| download | php-mozart-4e99773a3d203e73b8bf6464490d05649a269fa7.tar.gz php-mozart-4e99773a3d203e73b8bf6464490d05649a269fa7.tar.zst php-mozart-4e99773a3d203e73b8bf6464490d05649a269fa7.zip | |
test(commands): remove per-command tests
Diffstat (limited to 'crates/mozart/src/commands/show.rs')
| -rw-r--r-- | crates/mozart/src/commands/show.rs | 292 |
1 files changed, 0 insertions, 292 deletions
diff --git a/crates/mozart/src/commands/show.rs b/crates/mozart/src/commands/show.rs index 81eaaad..4049a18 100644 --- a/crates/mozart/src/commands/show.rs +++ b/crates/mozart/src/commands/show.rs @@ -2150,295 +2150,3 @@ fn normalize_version_simple(version: &str) -> String { } result } - -// ============================================================================ -// Tests -// ============================================================================ - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_format_license_for_show_osi_approved() { - let out = format_license_for_show("MIT"); - assert!( - out.contains("MIT License") && out.contains("(MIT)") && out.contains("(OSI approved)"), - "got: {out}", - ); - assert!( - out.contains("https://spdx.org/licenses/MIT.html#licenseText"), - "got: {out}", - ); - } - - #[test] - fn test_format_license_for_show_non_osi() { - let out = format_license_for_show("CC-BY-4.0"); - assert!( - out.contains("(CC-BY-4.0)") && !out.contains("(OSI approved)"), - "got: {out}", - ); - assert!( - out.contains("https://spdx.org/licenses/CC-BY-4.0.html#licenseText"), - "got: {out}", - ); - } - - #[test] - fn test_format_license_for_show_unknown_falls_back_to_id() { - assert_eq!(format_license_for_show("not-a-license"), "not-a-license"); - } - - #[test] - fn test_format_license_for_show_url_uses_canonical_id_casing() { - let out = format_license_for_show("mit"); - assert!( - out.contains("https://spdx.org/licenses/MIT.html#licenseText"), - "got: {out}", - ); - } - - #[test] - fn test_format_version_strips_v() { - assert_eq!(format_version("v1.2.3"), "1.2.3"); - } - - #[test] - fn test_format_version_no_v() { - assert_eq!(format_version("1.2.3"), "1.2.3"); - } - - #[test] - fn test_format_version_keeps_dev() { - assert_eq!(format_version("dev-main"), "dev-main"); - } - - #[test] - fn test_matches_wildcard_exact() { - assert!(matches_wildcard("psr/log", "psr/log")); - } - - #[test] - fn test_matches_wildcard_star_end() { - assert!(matches_wildcard("psr/log", "psr/*")); - } - - #[test] - fn test_matches_wildcard_star_start() { - assert!(matches_wildcard("psr/log", "*/log")); - } - - #[test] - fn test_matches_wildcard_star_middle() { - assert!(matches_wildcard("monolog/monolog", "mono*/mono*")); - } - - #[test] - fn test_matches_wildcard_no_match() { - assert!(!matches_wildcard("psr/log", "symfony/*")); - } - - #[test] - fn test_matches_wildcard_case_insensitive() { - assert!(matches_wildcard("PSR/Log", "psr/*")); - } - - #[test] - fn test_matches_wildcard_star_both_ends() { - assert!(matches_wildcard("monolog/monolog", "*log*")); - } - - #[test] - fn test_matches_wildcard_no_wildcard_mismatch() { - assert!(!matches_wildcard("psr/log", "psr/log2")); - } - - #[test] - fn test_matches_wildcard_trailing_chars_fail() { - assert!(!matches_wildcard("psr/log", "psr/l")); - } - - #[test] - fn test_format_version_highlight() { - assert_eq!(format_version_highlight("v3.0.0"), "* 3.0.0"); - assert_eq!(format_version_highlight("3.0.0"), "* 3.0.0"); - } - - #[test] - fn test_get_installed_description_present() { - let mut extra = indexmap::IndexMap::new(); - extra.insert( - "description".to_string(), - serde_json::Value::String("A logging library".to_string()), - ); - let pkg = mozart_core::repository::installed::InstalledPackageEntry { - name: "monolog/monolog".to_string(), - version: "3.0.0".to_string(), - version_normalized: None, - source: None, - dist: None, - package_type: None, - install_path: None, - autoload: None, - aliases: vec![], - homepage: None, - support: None, - extra_fields: extra, - }; - assert_eq!(get_installed_description(&pkg), "A logging library"); - } - - #[test] - fn test_get_installed_description_absent() { - let pkg = mozart_core::repository::installed::InstalledPackageEntry { - name: "psr/log".to_string(), - version: "3.0.0".to_string(), - version_normalized: None, - source: None, - dist: None, - package_type: None, - install_path: None, - autoload: None, - aliases: vec![], - homepage: None, - support: None, - extra_fields: indexmap::IndexMap::new(), - }; - assert_eq!(get_installed_description(&pkg), ""); - } - - #[test] - fn test_get_installed_keywords() { - let mut extra = indexmap::IndexMap::new(); - extra.insert( - "keywords".to_string(), - serde_json::json!(["log", "psr3", "logging"]), - ); - let pkg = mozart_core::repository::installed::InstalledPackageEntry { - name: "psr/log".to_string(), - version: "3.0.0".to_string(), - version_normalized: None, - source: None, - dist: None, - package_type: None, - install_path: None, - autoload: None, - aliases: vec![], - homepage: None, - support: None, - extra_fields: extra, - }; - assert_eq!( - get_installed_keywords_vec(&pkg).join(", "), - "log, psr3, logging" - ); - } - - #[test] - fn test_is_platform_package_php() { - assert!(is_platform_package("php")); - } - - #[test] - fn test_is_platform_package_ext() { - assert!(is_platform_package("ext-json")); - assert!(is_platform_package("ext-mbstring")); - } - - #[test] - fn test_is_platform_package_lib() { - assert!(is_platform_package("lib-pcre")); - } - - #[test] - fn test_is_platform_package_not_platform() { - assert!(!is_platform_package("monolog/monolog")); - assert!(!is_platform_package("psr/log")); - } - - #[test] - fn test_classify_up_to_date() { - assert_eq!( - classify_update_category("1.2.3.0", "1.2.3.0"), - ListUpdateKind::UpToDate - ); - } - - #[test] - fn test_classify_compatible_same_major() { - assert_eq!( - classify_update_category("1.2.0.0", "1.3.0.0"), - ListUpdateKind::Compatible - ); - } - - #[test] - fn test_classify_incompatible_different_major() { - assert_eq!( - classify_update_category("1.9.0.0", "2.0.0.0"), - ListUpdateKind::Incompatible - ); - } - - #[test] - fn test_normalize_version_simple_short() { - assert_eq!(normalize_version_simple("1.2"), "1.2.0.0"); - } - - #[test] - fn test_normalize_version_simple_three_parts() { - assert_eq!(normalize_version_simple("1.2.3"), "1.2.3.0"); - } - - #[test] - fn test_normalize_version_simple_v_prefix() { - assert_eq!(normalize_version_simple("v1.2.3"), "1.2.3.0"); - } - - #[test] - fn test_extract_major_basic() { - assert_eq!(extract_major("2.3.4.0"), 2); - assert_eq!(extract_major("0.1.2.0"), 0); - } - - #[test] - fn test_extract_major_with_prerelease() { - assert_eq!(extract_major("2.3.4.0-beta1"), 2); - } - - #[test] - fn test_extract_minor_basic() { - assert_eq!(extract_minor("2.3.4.0"), 3); - assert_eq!(extract_minor("1.0.0.0"), 0); - } - - #[test] - fn test_extract_minor_with_prerelease() { - assert_eq!(extract_minor("2.3.4.0-rc1"), 3); - } - - #[test] - fn test_abandoned_info_bool_true() { - let val = serde_json::Value::Bool(true); - assert_eq!(abandoned_info(&val), Some(String::new())); - } - - #[test] - fn test_abandoned_info_string_replacement() { - let val = serde_json::Value::String("other/package".to_string()); - assert_eq!(abandoned_info(&val), Some("other/package".to_string())); - } - - #[test] - fn test_abandoned_info_false() { - let val = serde_json::Value::Bool(false); - assert_eq!(abandoned_info(&val), None); - } - - #[test] - fn test_abandoned_info_string_false() { - let val = serde_json::Value::String("false".to_string()); - assert_eq!(abandoned_info(&val), None); - } -} |
