45 lines
1.0 KiB
Rust
45 lines
1.0 KiB
Rust
use axum::body::{to_bytes, Body};
|
|
use axum::http::{Request, StatusCode};
|
|
use tower::ServiceExt;
|
|
|
|
use desi_explorer_api::routes;
|
|
|
|
#[tokio::test]
|
|
async fn health_returns_ok() {
|
|
let app = routes::app();
|
|
|
|
let response = app
|
|
.oneshot(
|
|
Request::builder()
|
|
.uri("/health")
|
|
.body(Body::empty())
|
|
.unwrap(),
|
|
)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(response.status(), StatusCode::OK);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn catalogs_is_nonempty() {
|
|
let app = routes::app();
|
|
|
|
let response = app
|
|
.oneshot(
|
|
Request::builder()
|
|
.uri("/api/v1/catalogs")
|
|
.body(Body::empty())
|
|
.unwrap(),
|
|
)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(response.status(), StatusCode::OK);
|
|
|
|
let body = to_bytes(response.into_body(), usize::MAX).await.unwrap();
|
|
let json: serde_json::Value = serde_json::from_slice(&body).unwrap();
|
|
let catalogs = json.as_array().unwrap();
|
|
assert!(!catalogs.is_empty());
|
|
}
|