From 35f006a40485a7d09c0306cf6622e91c8b51ee97 Mon Sep 17 00:00:00 2001 From: Jessica Black Date: Tue, 25 Jun 2024 14:44:26 -0700 Subject: [PATCH] Add linux fetchers to locator --- Cargo.toml | 2 +- src/lib.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 74af75e..75b3920 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "locator" -version = "2.0.1" +version = "2.0.2" edition = "2021" [dependencies] diff --git a/src/lib.rs b/src/lib.rs index 3420425..267731a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -112,6 +112,21 @@ pub enum Fetcher { #[strum(serialize = "hex")] Hex, + /// Linux Alpine packages. + #[strum(serialize = "apk")] + #[serde(rename = "apk")] + LinuxAlpine, + + /// Linux Debian packages. + #[strum(serialize = "deb")] + #[serde(rename = "deb")] + LinuxDebian, + + /// Linux RPM packages. + #[strum(serialize = "rpm-generic")] + #[serde(rename = "rpm-generic")] + LinuxRpm, + /// Interacts with Maven. #[strum(serialize = "mvn")] Maven, @@ -395,4 +410,20 @@ mod tests { assert_eq!(package, test, "'package' must match in '{test}"); } } + + #[test] + fn serializes_linux_properly() { + assert_eq!( + r#""rpm-generic""#, + serde_json::to_string(&Fetcher::LinuxRpm).unwrap() + ); + assert_eq!( + r#""deb""#, + serde_json::to_string(&Fetcher::LinuxDebian).unwrap() + ); + assert_eq!( + r#""apk""#, + serde_json::to_string(&Fetcher::LinuxAlpine).unwrap() + ); + } }