Skip to content

Commit

Permalink
test: new tests for Package
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelemusiani committed Sep 14, 2024
1 parent 524f490 commit edef538
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
}

0 comments on commit edef538

Please sign in to comment.