From 028797335b419731982716da7bfa9a1a5cd4849b Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 20 Sep 2023 11:49:04 -0700 Subject: [PATCH] pubsys-setup: fix repo expiration deserialization bug Somehow there is a bug where the 2w-2w-1w.toml file cannot be deserialized because of a type error from serde. This fixes it and adds a test to make sure that does not happen again. --- tools/pubsys-config/src/lib.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/pubsys-config/src/lib.rs b/tools/pubsys-config/src/lib.rs index 8b244977e..5f9a1848a 100644 --- a/tools/pubsys-config/src/lib.rs +++ b/tools/pubsys-config/src/lib.rs @@ -241,8 +241,8 @@ fn deserialize_offset<'de, D>(deserializer: D) -> std::result::Result, { - let s: &str = Deserialize::deserialize(deserializer)?; - parse_offset(s).map_err(serde::de::Error::custom) + let s: String = Deserialize::deserialize(deserializer)?; + parse_offset(&s).map_err(serde::de::Error::custom) } mod error { @@ -277,3 +277,14 @@ mod error { } pub use error::Error; pub type Result = std::result::Result; + +#[test] +fn repo_expiration_deserialization_test() { + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("..") + .join("pubsys") + .join("policies") + .join("repo-expiration") + .join("2w-2w-1w.toml"); + let _ = RepoExpirationPolicy::from_path(path).unwrap(); +}