fix: where repo config is in server should register webhook
This commit is contained in:
parent
880fa0cc0e
commit
975c9e315c
3 changed files with 56 additions and 0 deletions
|
@ -4,6 +4,7 @@ stateDiagram-v2
|
||||||
|
|
||||||
CloneRepo --> LoadConfigFromRepo :on repo config
|
CloneRepo --> LoadConfigFromRepo :on repo config
|
||||||
CloneRepo --> ValidateRepo :on server config
|
CloneRepo --> ValidateRepo :on server config
|
||||||
|
CloneRepo --> RegisterWebhook :on server config
|
||||||
|
|
||||||
LoadConfigFromRepo --> ReceiveRepoConfig
|
LoadConfigFromRepo --> ReceiveRepoConfig
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,11 @@ impl Handler<actor::messages::CloneRepo> for actor::RepoActor {
|
||||||
&self.log,
|
&self.log,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
actor::do_send(
|
||||||
|
ctx.address(),
|
||||||
|
actor::messages::RegisterWebhook::new(),
|
||||||
|
&self.log,
|
||||||
|
);
|
||||||
actor::do_send(
|
actor::do_send(
|
||||||
ctx.address(),
|
ctx.address(),
|
||||||
actor::messages::ValidateRepo::new(self.message_token),
|
actor::messages::ValidateRepo::new(self.message_token),
|
||||||
|
|
|
@ -105,6 +105,56 @@ async fn when_server_has_no_repo_config_should_send_load_from_repo() -> TestResu
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The server config can optionally include the names of the main, next and dev
|
||||||
|
/// branches. When it does we should go straight to sending a [ValidateRepo] message.
|
||||||
|
#[actix::test]
|
||||||
|
async fn when_server_has_repo_config_should_send_validate_repo() -> TestResult {
|
||||||
|
//given
|
||||||
|
let fs = given::a_filesystem();
|
||||||
|
let (mut open_repository, repo_details) = given::an_open_repository(&fs);
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
given::has_all_valid_remote_defaults(&mut open_repository, &repo_details);
|
||||||
|
|
||||||
|
let mut repository_factory = MockRepositoryFactory::new();
|
||||||
|
expect::open_repository(&mut repository_factory, open_repository);
|
||||||
|
fs.dir_create(&repo_details.gitdir)?;
|
||||||
|
|
||||||
|
//when
|
||||||
|
let (addr, log) = when::start_actor(repository_factory, repo_details, given::a_forge());
|
||||||
|
addr.send(CloneRepo::new()).await?;
|
||||||
|
System::current().stop();
|
||||||
|
|
||||||
|
//then
|
||||||
|
log.require_message_containing("send: ValidateRepo")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The server config can optionally include the names of the main, next and dev
|
||||||
|
/// branches. When it does we should register the webhook by sending [RegisterWebhook] message.
|
||||||
|
#[actix::test]
|
||||||
|
async fn when_server_has_repo_config_should_send_register_webhook() -> TestResult {
|
||||||
|
//given
|
||||||
|
let fs = given::a_filesystem();
|
||||||
|
let (mut open_repository, repo_details) = given::an_open_repository(&fs);
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
given::has_all_valid_remote_defaults(&mut open_repository, &repo_details);
|
||||||
|
|
||||||
|
let mut repository_factory = MockRepositoryFactory::new();
|
||||||
|
expect::open_repository(&mut repository_factory, open_repository);
|
||||||
|
fs.dir_create(&repo_details.gitdir)?;
|
||||||
|
|
||||||
|
//when
|
||||||
|
let (addr, log) = when::start_actor(repository_factory, repo_details, given::a_forge());
|
||||||
|
addr.send(CloneRepo::new()).await?;
|
||||||
|
System::current().stop();
|
||||||
|
|
||||||
|
//then
|
||||||
|
log.require_message_containing("send: RegisterWebhook")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test_log::test(actix::test)]
|
#[test_log::test(actix::test)]
|
||||||
async fn opened_repo_with_no_default_push_should_not_proceed() -> TestResult {
|
async fn opened_repo_with_no_default_push_should_not_proceed() -> TestResult {
|
||||||
//given
|
//given
|
||||||
|
|
Loading…
Reference in a new issue