From 71f7606baf79ffa427389db7e98f62cbd69de45d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 22 Oct 2017 09:45:53 -0700 Subject: [PATCH] more tests --- src/error.rs | 13 ++++++++++--- src/multipart.rs | 9 +++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/error.rs b/src/error.rs index d89967763..1c94abd8d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -149,9 +149,9 @@ mod tests { use std::error::Error as StdError; use std::io; use httparse; - use http::StatusCode; + use http::{StatusCode, Error as HttpError}; use cookie::ParseError as CookieParseError; - use super::{ParseError, HttpResponse, HttpRangeParseError}; + use super::{ParseError, HttpResponse, HttpRangeParseError, MultipartError}; #[test] fn test_into_response() { @@ -163,7 +163,14 @@ mod tests { let resp: HttpResponse = CookieParseError::EmptyName.into(); assert_eq!(resp.status(), StatusCode::BAD_REQUEST); -} + + let resp: HttpResponse = MultipartError::Boundary.into(); + assert_eq!(resp.status(), StatusCode::BAD_REQUEST); + + let err: HttpError = StatusCode::from_u16(10000).err().unwrap().into(); + let resp: HttpResponse = err.into(); + assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR); + } #[test] fn test_cause() { diff --git a/src/multipart.rs b/src/multipart.rs index 09c73b633..d1ef60cbd 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -708,6 +708,15 @@ fn test_boundary() { _ => panic!("should not happen"), } + let mut headers = HeaderMap::new(); + headers.insert( + header::CONTENT_TYPE, + header::HeaderValue::from_static("multipart/mixed")); + match Multipart::boundary(&headers) { + Err(MultipartError::Boundary) => (), + _ => panic!("should not happen"), + } + let mut headers = HeaderMap::new(); headers.insert( header::CONTENT_TYPE,