Add a test for concurrent cli and dump

This commit is contained in:
Mubelotix
2025-07-31 09:35:16 +02:00
parent fc4c5d2718
commit f67043801b
3 changed files with 52 additions and 2 deletions

View File

@ -449,7 +449,7 @@ pub(crate) mod test {
let dump = DumpReader::open(dump).unwrap();
// top level infos
insta::assert_snapshot!(dump.date().unwrap(), @"2025-07-30 14:06:57.240882 +00:00:00");
insta::assert_snapshot!(dump.date().unwrap(), @"2025-07-31 7:28:28.091553 +00:00:00");
insta::assert_debug_snapshot!(dump.instance_uid().unwrap(), @r"
Some(
cb887dcc-34b3-48d1-addd-9815ae721a81,
@ -462,6 +462,12 @@ pub(crate) mod test {
insta::assert_json_snapshot!(webhooks, @r#"
{
"webhooks": {
"_cli": {
"url": "https://defined-in-dump.com/",
"headers": {
"Authorization": "Bearer defined in dump"
}
},
"exampleName": {
"url": "https://example.com/hook",
"headers": {

View File

@ -2,6 +2,7 @@
//! post requests. The webhook handle starts a server and forwards all the
//! received requests into a channel for you to handle.
use std::path::PathBuf;
use std::sync::Arc;
use actix_http::body::MessageBody;
@ -68,7 +69,7 @@ async fn create_webhook_server() -> WebhookHandle {
}
#[actix_web::test]
async fn test_cli_webhook() {
async fn cli_only() {
let WebhookHandle { server_handle, url, mut receiver } = create_webhook_server().await;
let db_path = tempfile::tempdir().unwrap();
@ -144,6 +145,49 @@ async fn test_cli_webhook() {
server_handle.abort();
}
#[actix_web::test]
async fn cli_with_dumps() {
let db_path = tempfile::tempdir().unwrap();
let server = Server::new_with_options(Opt {
task_webhook_url: Some(Url::parse("http://defined-in-test-cli.com").unwrap()),
task_webhook_authorization_header: Some(String::from("Bearer a-secret-token-defined-in-test-cli")),
import_dump: Some(PathBuf::from("../dump/tests/assets/v6-with-webhooks.dump")),
..default_settings(db_path.path())
})
.await
.unwrap();
let (webhooks, code) = server.get_webhooks().await;
snapshot!(code, @"200 OK");
snapshot!(webhooks, @r#"
{
"webhooks": {
"_cli": {
"url": "http://defined-in-test-cli.com/",
"headers": {
"Authorization": "Bearer a-secret-token-defined-in-test-cli"
}
},
"exampleName": {
"url": "https://example.com/hook",
"headers": {
"authorization": "TOKEN"
}
},
"otherName": {
"url": "https://example.com/authorization-less",
"headers": {}
},
"third": {
"url": "https://third.com",
"headers": {}
}
}
}
"#);
}
#[actix_web::test]
async fn reserved_names() {
let server = Server::new().await;