Test Expiring encode and decode
This commit is contained in:
parent
f2fed3726d
commit
0dace6bb6a
|
@ -93,8 +93,8 @@ impl Decodable for Expiring {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use chrono::{UTC, Duration};
|
||||
use rustc_serialize::json::Json;
|
||||
use chrono::{UTC, Duration, Timelike};
|
||||
use rustc_serialize::json::{self, Json};
|
||||
|
||||
use client::response::FromResponse;
|
||||
use super::Expiring;
|
||||
|
@ -120,4 +120,15 @@ mod tests {
|
|||
assert!(expiring.expires > UTC::now());
|
||||
assert!(expiring.expires <= UTC::now() + Duration::seconds(3600));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encode_decode() {
|
||||
let expiring = Expiring {
|
||||
refresh_token: String::from("foo"),
|
||||
expires: UTC::now().with_nanosecond(0).unwrap(),
|
||||
};
|
||||
let json = json::encode(&expiring).unwrap();
|
||||
let decoded = json::decode(&json).unwrap();
|
||||
assert_eq!(expiring, decoded);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue