feat: add human readable output to the API
This commit is contained in:
parent
f57ecd19aa
commit
183b2c2c88
6 changed files with 221 additions and 20 deletions
|
|
@ -81,6 +81,8 @@ pub struct CacheStatusResponse {
|
|||
pub status: DoorStatus,
|
||||
pub since: Option<u64>,
|
||||
pub last_checked: Option<u64>,
|
||||
#[serde(default)]
|
||||
pub human_readable: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -177,11 +179,13 @@ mod tests {
|
|||
status: DoorStatus::Closed,
|
||||
since: Some(123),
|
||||
last_checked: Some(456),
|
||||
human_readable: "We've been closed since Thursday, January 1, 1970 at 12:02 AM UTC, which was 2 minutes and 3 seconds ago. Last checked Thursday, January 1, 1970 at 12:07 AM UTC, which was 7 minutes and 36 seconds ago.".into(),
|
||||
};
|
||||
|
||||
let json = serde_json::to_value(&response).unwrap();
|
||||
assert_eq!(json["status"], "closed");
|
||||
assert_eq!(json["since"], 123);
|
||||
assert_eq!(json["last_checked"], 456);
|
||||
assert_eq!(json["human_readable"], response.human_readable);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue