1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 17:07:01 +02:00

more tests

This commit is contained in:
Nikolay Kim
2017-10-14 10:01:53 -07:00
parent 95987daa72
commit 5c9f813d28
3 changed files with 131 additions and 13 deletions

View File

@@ -45,3 +45,38 @@ impl From<StaticResponse> for HttpResponse {
st.response()
}
}
#[cfg(test)]
mod tests {
use http::StatusCode;
use super::{HTTPOk, HTTPBadRequest, Body, HttpResponse};
#[test]
fn test_builder() {
let resp = HTTPOk.builder().body(Body::Empty).unwrap();
assert_eq!(resp.status(), StatusCode::OK);
}
#[test]
fn test_response() {
let resp = HTTPOk.response();
assert_eq!(resp.status(), StatusCode::OK);
}
#[test]
fn test_from() {
let resp: HttpResponse = HTTPOk.into();
assert_eq!(resp.status(), StatusCode::OK);
}
#[test]
fn test_with_reason() {
let resp = HTTPOk.response();
assert_eq!(resp.reason(), "");
let resp = HTTPBadRequest.with_reason("test");
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
assert_eq!(resp.reason(), "test");
}
}