Test Expiring encode and decode
This commit is contained in:
parent
f2fed3726d
commit
0dace6bb6a
|
@ -93,8 +93,8 @@ impl Decodable for Expiring {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use chrono::{UTC, Duration};
|
use chrono::{UTC, Duration, Timelike};
|
||||||
use rustc_serialize::json::Json;
|
use rustc_serialize::json::{self, Json};
|
||||||
|
|
||||||
use client::response::FromResponse;
|
use client::response::FromResponse;
|
||||||
use super::Expiring;
|
use super::Expiring;
|
||||||
|
@ -120,4 +120,15 @@ mod tests {
|
||||||
assert!(expiring.expires > UTC::now());
|
assert!(expiring.expires > UTC::now());
|
||||||
assert!(expiring.expires <= UTC::now() + Duration::seconds(3600));
|
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