use loco_rs::testing::prelude::*; use serial_test::serial; use termi_api::app::App; #[tokio::test] #[serial] async fn can_get_comments() { request::(|request, ctx| async move { seed::(&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::(|request, ctx| async move { seed::(&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; }