60 lines
1.7 KiB
Rust
60 lines
1.7 KiB
Rust
use axum::{
|
|
body::Body,
|
|
http::{Method, Request, StatusCode},
|
|
};
|
|
use tower::ServiceExt;
|
|
|
|
fn build_app() -> axum::Router {
|
|
app_operation_system::build_router(app_operation_system::app::test_state())
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn operation_system_router_exposes_health_endpoint() {
|
|
let response = build_app()
|
|
.oneshot(
|
|
Request::builder()
|
|
.method(Method::GET)
|
|
.uri("/api/health")
|
|
.body(Body::empty())
|
|
.expect("request should build"),
|
|
)
|
|
.await
|
|
.expect("router should answer request");
|
|
|
|
assert_eq!(response.status(), StatusCode::OK);
|
|
}
|
|
|
|
/// Verify the station collection route is registered (DELETE on the collection
|
|
/// isn't a real method, so axum should answer METHOD_NOT_ALLOWED, not 404).
|
|
#[tokio::test]
|
|
async fn operation_system_router_exposes_station_collection() {
|
|
let response = build_app()
|
|
.oneshot(
|
|
Request::builder()
|
|
.method(Method::DELETE)
|
|
.uri("/api/station")
|
|
.body(Body::empty())
|
|
.expect("request should build"),
|
|
)
|
|
.await
|
|
.expect("router should answer request");
|
|
|
|
assert_eq!(response.status(), StatusCode::METHOD_NOT_ALLOWED);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn operation_system_router_exposes_segment_collection() {
|
|
let response = build_app()
|
|
.oneshot(
|
|
Request::builder()
|
|
.method(Method::DELETE)
|
|
.uri("/api/segment")
|
|
.body(Body::empty())
|
|
.expect("request should build"),
|
|
)
|
|
.await
|
|
.expect("router should answer request");
|
|
|
|
assert_eq!(response.status(), StatusCode::METHOD_NOT_ALLOWED);
|
|
}
|