diff options
Diffstat (limited to 'testing/tests/actix_web.rs')
-rw-r--r-- | testing/tests/actix_web.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/testing/tests/actix_web.rs b/testing/tests/actix_web.rs index d40830f..267736d 100644 --- a/testing/tests/actix_web.rs +++ b/testing/tests/actix_web.rs @@ -2,7 +2,7 @@ use actix_web::http::header::CONTENT_TYPE; use actix_web::test; use actix_web::HttpMessage; -use askama::Template; +use askama::{actix_web::TemplateResponder, Template}; use bytes::Bytes; #[derive(Template)] @@ -23,3 +23,21 @@ fn test_actix_web() { let bytes = srv.execute(response.body()).unwrap(); assert_eq!(bytes, Bytes::from_static("Hello, world!".as_ref())); } + +#[test] +fn test_actix_web_responder() { + let mut srv = test::TestServer::new(|app| { + app.handler(|_| { + let name = "world".to_owned(); + HelloTemplate { name: &name }.responder() + }) + }); + + let request = srv.get().finish().unwrap(); + let response = srv.execute(request.send()).unwrap(); + assert!(response.status().is_success()); + assert_eq!(response.headers().get(CONTENT_TYPE).unwrap(), "text/html"); + + let bytes = srv.execute(response.body()).unwrap(); + assert_eq!(bytes, Bytes::from_static("Hello, world!".as_ref())); +} |