diff --git a/src/lib.rs b/src/lib.rs index 34ea3af..1c9f2f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -218,5 +218,67 @@ mod test { assert_eq!(&pkg.version, "7.1.0"); assert_eq!(pkg.build_version, 18); assert!(matches!(pkg.arch, Arch::Any)); + + let pkg = Package::parse("zsa-udev-2.1.3.r14.gbceec97-1-any").unwrap(); + assert_eq!(&pkg.name, "zsa-udev"); + assert_eq!(&pkg.version, "2.1.3.r14.gbceec97"); + assert_eq!(pkg.build_version, 1); + assert!(matches!(pkg.arch, Arch::Any)); + } + + #[test] + fn full_name() { + let pkg = Package::parse("ibus-table-1.12.2-1-any").unwrap(); + assert_eq!(pkg.full_name(), "ibus-table-1.12.2-1-any"); + + let pkg = Package::parse("iec16022-0.3.0-3-x86_64").unwrap(); + assert_eq!(pkg.full_name(), "iec16022-0.3.0-3-x86_64"); + + let pkg = Package::parse("zsa-udev-2.1.3.r14.gbceec97-1-any").unwrap(); + assert_eq!(pkg.full_name(), "zsa-udev-2.1.3.r14.gbceec97-1-any"); + } + + #[test] + fn getters() { + let pkg = Package::parse("wakeonlan-0.42-2-any").unwrap(); + assert_eq!(pkg.name(), "wakeonlan"); + assert_eq!(pkg.version(), "0.42"); + assert_eq!(pkg.build_version(), 2); + assert!(matches!(pkg.arch(), Arch::Any)); + + let pkg = Package::parse("wanderlust-20240207-1-any").unwrap(); + assert_eq!(pkg.name(), "wanderlust"); + assert_eq!(pkg.version(), "20240207"); + assert_eq!(pkg.build_version(), 1); + assert!(matches!(pkg.arch(), Arch::Any)); + + let pkg = Package::parse("zsa-udev-2.1.3.r12.g7ce7ff3-2-any").unwrap(); + assert_eq!(pkg.name(), "zsa-udev"); + assert_eq!(pkg.version(), "2.1.3.r12.g7ce7ff3"); + assert_eq!(pkg.build_version(), 2); + assert!(matches!(pkg.arch(), Arch::Any)); + + let pkg = Package::parse("zita-resampler-1.11.2-1-x86_64").unwrap(); + assert_eq!(pkg.name(), "zita-resampler"); + assert_eq!(pkg.version(), "1.11.2"); + assert_eq!(pkg.build_version(), 1); + assert!(matches!(pkg.arch(), Arch::X86_64)); + } + + #[test] + fn get_url() { + let pkg = Package::parse("id3lib-3.8.3-18-x86_64").unwrap(); + let url = pkg.get_url().unwrap(); + assert_eq!( + url, + "https://archive.archlinux.org/packages/i/id3lib/id3lib-3.8.3-18-x86_64.pkg.tar.zst" + ); + + let pkg = Package::parse("caddy-1.0.4-2-x86_64").unwrap(); + let url = pkg.get_url().unwrap(); + assert_eq!( + url, + "https://archive.archlinux.org/packages/c/caddy/caddy-1.0.4-2-x86_64.pkg.tar.xz" + ); } }