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