Test Expiring encode and decode

This commit is contained in:
Curtis McEnroe 2015-12-25 17:46:38 -05:00
parent f2fed3726d
commit 0dace6bb6a
1 changed files with 13 additions and 2 deletions

View File

@ -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);
}
} }