Move hagrid::web::tests::common::assert::check_maintenance() helper to hagrid::routes::tests::common::assert::maintenance::check_maintenance().

Additional changes:
- Adjust imports and usages accordingly.
This commit is contained in:
Zeke Fast
2025-09-08 17:34:27 +02:00
committed by Vincent Breitmoser
parent 3ce6e8b495
commit 63a4445c9f
2 changed files with 24 additions and 20 deletions

View File

@@ -244,6 +244,23 @@ pub mod tests {
println!("{body}");
assert!(!body.contains(absent_page_text));
}
pub mod maintenance {
use super::*;
pub fn check_maintenance(
response: LocalResponse,
content_type: ContentType,
maintenance_text: &str,
) {
super::response(
response,
Status::ServiceUnavailable,
content_type,
maintenance_text,
);
}
}
}
}

View File

@@ -324,19 +324,6 @@ pub mod tests {
use std::path::Path;
use std::time::SystemTime;
pub fn check_maintenance(
response: LocalResponse,
content_type: ContentType,
maintenance_text: &str,
) {
crate::routes::tests::common::assert::response(
response,
Status::ServiceUnavailable,
content_type,
maintenance_text,
);
}
/// Asserts that the given URI 404s.
pub fn check_null_response(client: &Client, uri: &str) {
let response = client.get(uri).dispatch();
@@ -832,39 +819,39 @@ pub mod tests {
file.write_all(maintenance_text.as_bytes()).unwrap();
// Check that endpoints return a maintenance message
common::assert::check_maintenance(
assert::maintenance::check_maintenance(
client.get("/upload").dispatch(),
ContentType::HTML,
maintenance_text,
);
common::assert::check_maintenance(
assert::maintenance::check_maintenance(
client.get("/manage").dispatch(),
ContentType::HTML,
maintenance_text,
);
common::assert::check_maintenance(
assert::maintenance::check_maintenance(
client.get("/verify").dispatch(),
ContentType::HTML,
maintenance_text,
);
common::assert::check_maintenance(
assert::maintenance::check_maintenance(
client.get("/pks/add").dispatch(),
ContentType::Plain,
maintenance_text,
);
common::assert::check_maintenance(
assert::maintenance::check_maintenance(
client.get("/vks/v1/upload").dispatch(),
ContentType::JSON,
maintenance_text,
);
common::assert::check_maintenance(
assert::maintenance::check_maintenance(
client.get("/vks/v1/request-verify").dispatch(),
ContentType::JSON,
maintenance_text,
);
// Extra check for the shortcut "PUT" endpoint
common::assert::check_maintenance(
assert::maintenance::check_maintenance(
client.put("/").dispatch(),
ContentType::Plain,
maintenance_text,