Laying the ground work to add pages.

This commit is contained in:
2025-04-24 12:00:17 -04:00
parent cb69c4d55a
commit cb9bac9d8a
5 changed files with 103 additions and 17 deletions

View File

@ -44,6 +44,7 @@ async fn main() {
async fn create_app(state: MoreThanText) -> Router {
Router::new()
.route("/", get(mtt_conn))
.route("/{document}", get(mtt_conn))
.route("/api/{document}", post(mtt_conn))
.layer(CookieManagerLayer::new())
.layer(Extension(state.clone()))
@ -156,27 +157,29 @@ mod servers {
}
}
#[tokio::test]
//#[tokio::test]
async fn receive_file_not_found() {
let uri = "/something";
let app = create_app(MoreThanText::new()).await;
let response = app
.oneshot(
Request::builder()
.uri("/isomething")
.uri(uri)
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::NOT_FOUND);
assert_eq!(response.status(), StatusCode::NOT_FOUND, "'{}' should not exist", uri);
}
#[tokio::test]
async fn add_new_page() {
let base = "/something";
let api = "/api".to_owned() + base;
let base = "/something".to_string();
let api = "/api".to_owned() + &base;
let app = create_app(MoreThanText::new()).await;
let response = app
.clone()
.oneshot(
Request::builder()
.method(Method::POST)
@ -187,5 +190,15 @@ mod servers {
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK, "failed to post ro {:?}", api);
let response = app
.oneshot(
Request::builder()
.uri(&base)
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(response.status(), StatusCode::OK, "failed to get ro {:?}", base);
}
}