aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-28 21:26:13 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-29 09:25:59 +0100
commitb56c11639f9ea5ef1354a1e91ca98541a16bca9b (patch)
tree11933ea82d131d0b1efe64aed64ce1705f6f7d0a /testing
parent9026f616e620426535bf095848fe355e25911d62 (diff)
downloadaskama-b56c11639f9ea5ef1354a1e91ca98541a16bca9b.tar.gz
askama-b56c11639f9ea5ef1354a1e91ca98541a16bca9b.tar.bz2
askama-b56c11639f9ea5ef1354a1e91ca98541a16bca9b.zip
Move Actix-Web integration into separate askama_actix crate
Diffstat (limited to 'testing')
-rw-r--r--testing/Cargo.toml7
-rw-r--r--testing/tests/actix_web.rs54
2 files changed, 1 insertions, 60 deletions
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index f093892..e7b9668 100644
--- a/testing/Cargo.toml
+++ b/testing/Cargo.toml
@@ -6,20 +6,15 @@ workspace = ".."
edition = "2018"
[features]
-actix = ["actix-web", "actix-rt", "bytes", "askama/with-actix-web", "futures"]
default = []
-full = ["actix", "with-iron", "serde-json", "with-gotham"]
+full = ["with-iron", "serde-json", "with-gotham"]
serde-json = ["serde_json", "askama/serde-json"]
with-rocket = ["rocket", "askama/with-rocket"]
with-iron = ["iron", "askama/with-iron"]
with-gotham = ["gotham", "askama/with-gotham", "mime", "hyper"]
[dependencies]
-actix-web = { version = "2", optional = true }
-actix-rt = { version = "1", optional = true }
-futures = { version = "0.3", optional = true }
askama = { path = "../askama", version = "*" }
-bytes = { version = "0.5", optional = true }
iron = { version = "0.6", optional = true }
rocket = { version = "0.4", default-features = false, optional = true }
serde_json = { version = "1.0", optional = true }
diff --git a/testing/tests/actix_web.rs b/testing/tests/actix_web.rs
deleted file mode 100644
index 8beef3d..0000000
--- a/testing/tests/actix_web.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-#![cfg(feature = "actix")]
-use actix_web::http::header::CONTENT_TYPE;
-use actix_web::test;
-use actix_web::web;
-use askama::{actix_web::TemplateIntoResponse, Template};
-use bytes::Bytes;
-
-#[derive(Template)]
-#[template(path = "hello.html")]
-struct HelloTemplate<'a> {
- name: &'a str,
-}
-
-#[actix_rt::test]
-async fn test_actix_web() {
- let srv = test::start(|| {
- actix_web::App::new()
- .service(web::resource("/").to(|| async { HelloTemplate { name: "world" } }))
- });
-
- let request = srv.get("/");
- let mut response = request.send().await.unwrap();
- assert!(response.status().is_success());
- assert_eq!(
- response.headers().get(CONTENT_TYPE).unwrap(),
- "text/html; charset=utf-8"
- );
-
- let bytes = response.body().await.unwrap();
- assert_eq!(bytes, Bytes::from_static("Hello, world!".as_ref()));
-}
-
-#[actix_rt::test]
-async fn test_actix_web_responder() {
- let srv = test::start(|| {
- actix_web::App::new().service(web::resource("/").to(|| {
- async {
- let name = "world".to_owned();
- HelloTemplate { name: &name }.into_response()
- }
- }))
- });
-
- let request = srv.get("/");
- let mut response = request.send().await.unwrap();
- assert!(response.status().is_success());
- assert_eq!(
- response.headers().get(CONTENT_TYPE).unwrap(),
- "text/html; charset=utf-8"
- );
-
- let bytes = response.body().await.unwrap();
- assert_eq!(bytes, Bytes::from_static("Hello, world!".as_ref()));
-}