Test Static::from_response

This commit is contained in:
Curtis McEnroe 2015-12-23 23:54:56 -05:00
parent 2bde28f1de
commit e09b0726fe
1 changed files with 23 additions and 0 deletions

View File

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