From 75f32d3967e4d13b86b0d720ebc808c6fd9caa05 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 28 Jan 2020 22:17:22 +0100 Subject: Move Gotham integration into separate askama_gotham crate --- testing/Cargo.toml | 6 +----- testing/tests/gotham.rs | 42 ------------------------------------------ 2 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 testing/tests/gotham.rs (limited to 'testing') diff --git a/testing/Cargo.toml b/testing/Cargo.toml index 424dd73..5517047 100644 --- a/testing/Cargo.toml +++ b/testing/Cargo.toml @@ -7,18 +7,14 @@ edition = "2018" [features] default = [] -full = ["with-iron", "serde-json", "with-gotham"] +full = ["with-iron", "serde-json"] serde-json = ["serde_json", "askama/serde-json"] with-iron = ["iron", "askama/with-iron"] -with-gotham = ["gotham", "askama/with-gotham", "mime", "hyper"] [dependencies] askama = { path = "../askama", version = "*" } iron = { version = "0.6", optional = true } serde_json = { version = "1.0", optional = true } -gotham = { version = "0.3", default-features = false, optional = true } -mime = { version = "0.3", optional = true } -hyper = { version = "0.12", optional = true } [dev-dependencies] criterion = "0.3" diff --git a/testing/tests/gotham.rs b/testing/tests/gotham.rs deleted file mode 100644 index 225a0ef..0000000 --- a/testing/tests/gotham.rs +++ /dev/null @@ -1,42 +0,0 @@ -#![cfg(feature = "with-gotham")] - -use askama::Template; -use gotham::state::State; -use gotham::test::TestServer; -use hyper::StatusCode; - -#[derive(Template)] -#[template(path = "hello.html")] -struct HelloTemplate<'a> { - name: &'a str, -} - -fn hello(state: State) -> (State, HelloTemplate<'static>) { - (state, HelloTemplate { name: "world" }) -} - -#[test] -fn test_gotham() { - let test_server = TestServer::new(|| Ok(hello)).expect("Failed to mount test router"); - - let res = test_server - .client() - .get("http://localhost/") - .perform() - .expect("Failed to send request to gotham"); - - assert_eq!(res.status(), StatusCode::OK); - { - let headers = res.headers(); - let content_type = headers - .get("content-type") - .expect("Response did not contain content-type header"); - assert_eq!( - content_type.to_str().unwrap(), - mime::TEXT_HTML_UTF_8.to_string() - ); - } - - let body = res.read_utf8_body().expect("failed to read response body"); - assert_eq!(&body, "Hello, world!"); -} -- cgit