chore: reorganize project into monorepo
This commit is contained in:
35
backend/tests/requests/comment.rs
Normal file
35
backend/tests/requests/comment.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use loco_rs::testing::prelude::*;
|
||||
use serial_test::serial;
|
||||
use termi_api::app::App;
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn can_get_comments() {
|
||||
request::<App, _, _>(|request, ctx| async move {
|
||||
seed::<App>(&ctx).await.unwrap();
|
||||
|
||||
let res = request.get("/api/comments/").await;
|
||||
assert_eq!(res.status_code(), 200);
|
||||
assert!(res.text().contains("\"author\":\"Alice\""));
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn can_filter_comments_by_post_slug() {
|
||||
request::<App, _, _>(|request, ctx| async move {
|
||||
seed::<App>(&ctx).await.unwrap();
|
||||
|
||||
let res = request
|
||||
.get("/api/comments/?post_slug=rust-programming-tips")
|
||||
.await;
|
||||
assert_eq!(res.status_code(), 200);
|
||||
|
||||
let body = res.text();
|
||||
assert!(body.contains("\"author\":\"Charlie\""));
|
||||
assert!(body.contains("\"author\":\"Grace\""));
|
||||
assert!(!body.contains("\"author\":\"Alice\""));
|
||||
})
|
||||
.await;
|
||||
}
|
||||
Reference in New Issue
Block a user