forked from Ruderverein-Donau-Linz/rowt
push
This commit is contained in:
parent
bb8fb03b61
commit
546381511e
1253
Cargo.lock
generated
1253
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -7,5 +7,8 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
rocket = { version = "0.5.0-rc.3"}
|
||||
rocket_dyn_templates = {version = "0.1.0-rc.3", features = [ "tera" ] }
|
||||
log = "0.4"
|
||||
env_logger = "0.10"
|
||||
sqlx = { version = "0.6", features = ["sqlite", "runtime-tokio-rustls"] }
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
use rocket::{get, routes, Build, Rocket};
|
||||
use rocket_dyn_templates::Template;
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> &'static str {
|
||||
@ -6,22 +7,37 @@ fn index() -> &'static str {
|
||||
}
|
||||
|
||||
pub fn start() -> Rocket<Build> {
|
||||
rocket::build().mount("/", routes![index])
|
||||
rocket::build()
|
||||
.mount("/", routes![index])
|
||||
.attach(Template::fairing())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::start;
|
||||
use rocket::http::Status;
|
||||
use rocket::local::blocking::Client;
|
||||
use rocket::local::asynchronous::Client;
|
||||
use rocket::uri;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[test]
|
||||
#[sqlx::test]
|
||||
fn hello_world() {
|
||||
let client = Client::tracked(start()).expect("valid rocket instance");
|
||||
let response = client.get(uri!(super::index)).dispatch();
|
||||
let pool = SqlitePool::connect(":memory:").await.unwrap();
|
||||
sqlx::query_file!("./migration.sql")
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
sqlx::query_file!("./seeds.sql")
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let client = Client::tracked(start())
|
||||
.await
|
||||
.expect("valid rocket instance");
|
||||
let response = client.get(uri!(super::index)).dispatch().await;
|
||||
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
assert_eq!(response.into_string(), Some("Hello, world!".into()));
|
||||
assert_eq!(response.into_string().await, Some("Hello, world!".into()));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user