pacenotes_shared/
key_status.rs1#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
5pub struct KeyStatus {
6 pub expires_at: Option<i64>,
8}
9
10#[cfg(test)]
11mod tests {
12 #[test]
13 fn key_status_round_trips_with_and_without_expiry() {
14 for status in [
15 super::KeyStatus { expires_at: None },
16 super::KeyStatus {
17 expires_at: Some(1_900_000_000),
18 },
19 ] {
20 let json = serde_json::to_string(&status).unwrap();
21 let back: super::KeyStatus = serde_json::from_str(&json).unwrap();
22 assert_eq!(back, status);
23 }
24 }
25
26 #[test]
28 fn a_key_that_never_expires_says_so_explicitly() {
29 assert_eq!(
30 serde_json::to_string(&super::KeyStatus { expires_at: None }).unwrap(),
31 r#"{"expires_at":null}"#
32 );
33 }
34}