use std::sync::Arc;

use axum::{
    body::Body,
    http::{Request, StatusCode},
};
use felicia::{config::AppConfig, startup};
use tower::ServiceExt;

#[tokio::test]
async fn health_check_succeeds_with_correct_code() -> anyhow::Result<()> {
    let config = Arc::new(AppConfig::new()?);
    let app = startup::create_app(config.clone()).await?;

    let response = app
        .oneshot(Request::builder().uri("/healthcheck").body(Body::empty())?)
        .await?;

    assert_eq!(response.status(), StatusCode::NO_CONTENT);

    Ok(())
}
