testing setup route
This commit is contained in:
parent
55fd5565d7
commit
f2bea92272
2 changed files with 30 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ pub fn routes() -> Vec<Route> {
|
|||
|
||||
#[get("/")]
|
||||
async fn setup_completed(_setup: CompletedSetup) -> Redirect {
|
||||
Redirect::to(uri!(super::root::homepage))
|
||||
Redirect::to(uri!("/"))
|
||||
}
|
||||
|
||||
#[get("/", rank = 2)]
|
||||
|
|
@ -59,3 +59,31 @@ async fn create_first_account(
|
|||
|
||||
Ok(Redirect::to(uri!("/")))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::tests::*;
|
||||
|
||||
#[test]
|
||||
fn setup() {
|
||||
// Setup http server
|
||||
let client = setup_rocket_testing();
|
||||
|
||||
// Make request
|
||||
let setup_page = client.get(uri!("/setup")).dispatch();
|
||||
assert_eq!(setup_page.status(), Status::Ok);
|
||||
|
||||
// Create account
|
||||
let create_account = client
|
||||
.post(uri!("/setup"))
|
||||
.header(ContentType::Form)
|
||||
.body(r#"username=phil&password=password"#)
|
||||
.dispatch();
|
||||
assert_ne!(create_account.status(), Status::UnprocessableEntity);
|
||||
assert_ne!(create_account.status(), Status::InternalServerError);
|
||||
|
||||
// Make request again, make sure its not OK
|
||||
let setup_page_after_creation = client.get(uri!("/setup")).dispatch();
|
||||
assert_ne!(setup_page_after_creation.status(), Status::Ok);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::rocket_setup;
|
|||
use rocket::local::blocking::Client;
|
||||
use rocket::{Build, Rocket};
|
||||
|
||||
pub use rocket::http::Status;
|
||||
pub use rocket::http::{ContentType, Status};
|
||||
pub use rocket::uri;
|
||||
|
||||
fn rocket_with_memory_database() -> Rocket<Build> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue