From c9efbb993692a4a106d96eafb149e04f3aca0458 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 30 Jun 2024 16:59:24 +0100 Subject: [PATCH] fix: ReceiveRepoConfig tries to send two messages Similar to CloneRepo the handler tries to send two messages one after the other. Leave it to WebhookRegistered handler to kick off the ValidateRepo. Also update the README with the correct message sequence. --- crates/repo-actor/README.md | 1 - .../src/handlers/receive_repo_config.rs | 6 ---- .../src/tests/handlers/loaded_config.rs | 30 ------------------- 3 files changed, 37 deletions(-) diff --git a/crates/repo-actor/README.md b/crates/repo-actor/README.md index 631ea69..217bae1 100644 --- a/crates/repo-actor/README.md +++ b/crates/repo-actor/README.md @@ -3,7 +3,6 @@ stateDiagram-v2 [*] --> CloneRepo :on start CloneRepo --> LoadConfigFromRepo :on repo config -CloneRepo --> ValidateRepo :on server config CloneRepo --> RegisterWebhook :on server config LoadConfigFromRepo --> ReceiveRepoConfig diff --git a/crates/repo-actor/src/handlers/receive_repo_config.rs b/crates/repo-actor/src/handlers/receive_repo_config.rs index b164250..2572d5a 100644 --- a/crates/repo-actor/src/handlers/receive_repo_config.rs +++ b/crates/repo-actor/src/handlers/receive_repo_config.rs @@ -14,12 +14,6 @@ impl Handler for actor::RepoActor { let repo_config = msg.unwrap(); self.repo_details.repo_config.replace(repo_config); - actor::do_send( - ctx.address(), - actor::messages::ValidateRepo::new(self.message_token), - &self.log, - ); - actor::do_send( ctx.address(), actor::messages::RegisterWebhook::new(), diff --git a/crates/repo-actor/src/tests/handlers/loaded_config.rs b/crates/repo-actor/src/tests/handlers/loaded_config.rs index b7b4a45..963cade 100644 --- a/crates/repo-actor/src/tests/handlers/loaded_config.rs +++ b/crates/repo-actor/src/tests/handlers/loaded_config.rs @@ -32,36 +32,6 @@ async fn should_store_repo_config_in_actor() -> TestResult { Ok(()) } -#[actix::test] -async fn should_validate_repo() -> TestResult { - //given - let fs = given::a_filesystem(); - let (open_repository, repo_details) = given::an_open_repository(&fs); - - let new_repo_config = given::a_repo_config(); - - //when - let (addr, log) = when::start_actor_with_open_repository( - Box::new(open_repository), - repo_details, - given::a_forge(), - ); - addr.send(actor::messages::ReceiveRepoConfig::new( - new_repo_config.clone(), - )) - .await?; - System::current().stop(); - - //then - tracing::debug!(?log, ""); - log.read().map_err(|e| e.to_string()).map(|l| { - assert!(l - .iter() - .any(|message| message.contains("send: ValidateRepo"))) - })?; - Ok(()) -} - #[actix::test] async fn should_register_webhook() -> TestResult { //given