From e09b0726fe307f41010028e21f661ab516058f10 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 23 Dec 2015 23:54:56 -0500 Subject: [PATCH] Test Static::from_response --- src/token/statik.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/token/statik.rs b/src/token/statik.rs index df3c78b..ece2bac 100644 --- a/src/token/statik.rs +++ b/src/token/statik.rs @@ -20,3 +20,26 @@ impl FromResponse for Static { Ok(Static) } } + +#[cfg(test)] +mod tests { + use rustc_serialize::json::Json; + + use client::response::{FromResponse, ParseError}; + use super::Static; + + #[test] + fn from_response() { + let json = Json::from_str("{}").unwrap(); + assert_eq!(Static, Static::from_response(&json).unwrap()); + } + + #[test] + fn from_response_with_expires_in() { + let json = Json::from_str(r#"{"expires_in":3600}"#).unwrap(); + assert_eq!( + ParseError::UnexpectedField("expires_in"), + Static::from_response(&json).unwrap_err() + ); + } +}