test: Add tests for xml and toml
This commit is contained in:
@@ -140,6 +140,12 @@ async fn test_main() -> anyhow::Result<()> {
|
||||
post(msgpack::extract_msgpack_raw),
|
||||
);
|
||||
|
||||
#[cfg(feature = "xml")]
|
||||
let router = router.route(xml::route::XML, post(xml::extract_xml));
|
||||
|
||||
#[cfg(feature = "toml")]
|
||||
let router = router.route(toml::route::TOML, post(toml::extract_toml));
|
||||
|
||||
let router = router.with_state(MyState::default());
|
||||
|
||||
let listener = TcpListener::bind(&SocketAddr::from(([0u8, 0, 0, 0], 0u16))).await?;
|
||||
@@ -388,6 +394,22 @@ async fn test_main() -> anyhow::Result<()> {
|
||||
.await?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "xml")]
|
||||
{
|
||||
use axum_serde::Xml;
|
||||
test_executor
|
||||
.execute::<Xml<ParametersGarde>>(Method::POST, xml::route::XML)
|
||||
.await?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "toml")]
|
||||
{
|
||||
use axum_serde::Toml;
|
||||
test_executor
|
||||
.execute::<Toml<ParametersGarde>>(Method::POST, toml::route::TOML)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -887,3 +909,35 @@ mod msgpack {
|
||||
validate_again(parameters, ())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "xml")]
|
||||
mod xml {
|
||||
use super::{validate_again, ParametersGarde};
|
||||
use crate::Garde;
|
||||
use axum::http::StatusCode;
|
||||
use axum_serde::Xml;
|
||||
|
||||
pub mod route {
|
||||
pub const XML: &str = "/xml";
|
||||
}
|
||||
|
||||
pub async fn extract_xml(Garde(Xml(parameters)): Garde<Xml<ParametersGarde>>) -> StatusCode {
|
||||
validate_again(parameters, ())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "toml")]
|
||||
mod toml {
|
||||
use super::{validate_again, ParametersGarde};
|
||||
use crate::Garde;
|
||||
use axum::http::StatusCode;
|
||||
use axum_serde::Toml;
|
||||
|
||||
pub mod route {
|
||||
pub const TOML: &str = "/toml";
|
||||
}
|
||||
|
||||
pub async fn extract_toml(Garde(Toml(parameters)): Garde<Toml<ParametersGarde>>) -> StatusCode {
|
||||
validate_again(parameters, ())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user