aboutsummaryrefslogtreecommitdiffstats
path: root/askama_rocket/tests/basic.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-28 22:06:11 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-29 09:25:59 +0100
commitc6f9a053c7328e6c782508114bd96aa569b5de7d (patch)
tree362ef1f8ef421eb5913fa2834c10f6743e1ca7e1 /askama_rocket/tests/basic.rs
parentb56c11639f9ea5ef1354a1e91ca98541a16bca9b (diff)
downloadaskama-c6f9a053c7328e6c782508114bd96aa569b5de7d.tar.gz
askama-c6f9a053c7328e6c782508114bd96aa569b5de7d.tar.bz2
askama-c6f9a053c7328e6c782508114bd96aa569b5de7d.zip
Move Rocket integration into askama_rocket crate
Diffstat (limited to 'askama_rocket/tests/basic.rs')
-rw-r--r--askama_rocket/tests/basic.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/askama_rocket/tests/basic.rs b/askama_rocket/tests/basic.rs
new file mode 100644
index 0000000..0671c4c
--- /dev/null
+++ b/askama_rocket/tests/basic.rs
@@ -0,0 +1,30 @@
+#![feature(proc_macro_hygiene, decl_macro)]
+
+#[macro_use]
+extern crate rocket;
+
+use askama::Template;
+
+use rocket::http::{ContentType, Status};
+use rocket::local::Client;
+
+#[derive(Template)]
+#[template(path = "hello.html")]
+struct HelloTemplate<'a> {
+ name: &'a str,
+}
+
+#[get("/")]
+fn hello() -> HelloTemplate<'static> {
+ HelloTemplate { name: "world" }
+}
+
+#[test]
+fn test_rocket() {
+ let rocket = rocket::ignite().mount("/", routes![hello]);
+ let client = Client::new(rocket).unwrap();
+ let mut rsp = client.get("/").dispatch();
+ assert_eq!(rsp.status(), Status::Ok);
+ assert_eq!(rsp.content_type(), Some(ContentType::HTML));
+ assert_eq!(rsp.body_string().unwrap(), "Hello, world!");
+}