From 5cdffd6e0e9eb0a408cec6e5a143231e139970fe Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Thu, 16 Jun 2022 07:44:06 +0200 Subject: Update to Rocket 0.5 Though Rocket 0.5 still only a release candidate, Rocket 0.4 severely outdated, and depends on a bunch of crates with active security advisories. Rocket 0.5 updates its dependencies to fixes versions. Also Rocket 0.4 needs a nightly Rust, which caused multiple problems. --- askama_rocket/tests/basic.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'askama_rocket/tests/basic.rs') diff --git a/askama_rocket/tests/basic.rs b/askama_rocket/tests/basic.rs index 0671c4c..a61c188 100644 --- a/askama_rocket/tests/basic.rs +++ b/askama_rocket/tests/basic.rs @@ -1,12 +1,8 @@ -#![feature(proc_macro_hygiene, decl_macro)] - -#[macro_use] -extern crate rocket; - use askama::Template; +use futures_lite::future::block_on; use rocket::http::{ContentType, Status}; -use rocket::local::Client; +use rocket::local::asynchronous::Client; #[derive(Template)] #[template(path = "hello.html")] @@ -14,17 +10,23 @@ struct HelloTemplate<'a> { name: &'a str, } -#[get("/")] +#[rocket::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!"); + block_on(async { + let rocket = rocket::build() + .mount("/", rocket::routes![hello]) + .ignite() + .await + .unwrap(); + let client = Client::untracked(rocket).await.unwrap(); + let rsp = client.get("/").dispatch().await; + assert_eq!(rsp.status(), Status::Ok); + assert_eq!(rsp.content_type(), Some(ContentType::HTML)); + assert_eq!(rsp.into_string().await.as_deref(), Some("Hello, world!")); + }); } -- cgit