Got content added to new pages.

This commit is contained in:
2025-05-02 18:04:17 -04:00
parent 57a09461f1
commit ea825c89eb
7 changed files with 47 additions and 14 deletions

View File

@ -85,6 +85,7 @@ async fn mtt_conn(
method: Method,
path: Path<HashMap<String, String>>,
state: State<MoreThanText>,
body: String,
) -> impl IntoResponse {
let (tx, mut rx) = channel(1);
let action = match method {
@ -97,7 +98,7 @@ async fn mtt_conn(
None => "root".to_string(),
};
spawn(async move {
tx.send(state.get_document(sess_id.0, action, doc))
tx.send(state.get_document(sess_id.0, action, doc, body))
.await
.unwrap();
});
@ -112,7 +113,6 @@ async fn mtt_conn(
#[cfg(test)]
mod servers {
use super::*;
use std::time::Duration;
use axum::{
body::Body,
http::{
@ -120,6 +120,9 @@ mod servers {
Method, Request,
},
};
use http_body_util::BodyExt;
use serde_json::json;
use std::time::Duration;
use tower::ServiceExt;
#[tokio::test]
@ -197,6 +200,10 @@ mod servers {
async fn add_new_page() {
let base = "/something".to_string();
let api = format!("/api{}", &base);
let content = format!("content-{}", Uuid::new_v4());
let document = json!({
"template": content.clone()
});
let app = create_app(MoreThanText::new()).await;
let response = app
.clone()
@ -204,7 +211,7 @@ mod servers {
Request::builder()
.method(Method::POST)
.uri(&api)
.body(Body::empty())
.body(document.to_string())
.unwrap(),
)
.await
@ -225,5 +232,7 @@ mod servers {
"failed to get ro {:?}",
base
);
let body = response.into_body().collect().await.unwrap().to_bytes();
assert_eq!(body, content);
}
}