Compare commits

...

2 commits

Author SHA1 Message Date
975c9e315c fix: where repo config is in server should register webhook
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Rust / build (push) Successful in 1m19s
2024-06-30 08:09:10 +01:00
880fa0cc0e chore: bacon run job runs server
All checks were successful
Rust / build (push) Successful in 1m22s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
2024-06-30 08:08:44 +01:00
4 changed files with 57 additions and 1 deletions

View file

@ -57,7 +57,7 @@ on_success = "back" # so that
# If you want to pass options to your program, a `--` separator
# will be needed.
[jobs.run]
command = ["cargo", "run", "--color", "always"]
command = ["cargo", "run", "--color", "always", "--", "server", "start"]
need_stdout = true
allow_warnings = true

View file

@ -4,6 +4,7 @@ stateDiagram-v2
CloneRepo --> LoadConfigFromRepo :on repo config
CloneRepo --> ValidateRepo :on server config
CloneRepo --> RegisterWebhook :on server config
LoadConfigFromRepo --> ReceiveRepoConfig

View file

@ -27,6 +27,11 @@ impl Handler<actor::messages::CloneRepo> for actor::RepoActor {
&self.log,
);
} else {
actor::do_send(
ctx.address(),
actor::messages::RegisterWebhook::new(),
&self.log,
);
actor::do_send(
ctx.address(),
actor::messages::ValidateRepo::new(self.message_token),

View file

@ -105,6 +105,56 @@ async fn when_server_has_no_repo_config_should_send_load_from_repo() -> TestResu
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)]
async fn opened_repo_with_no_default_push_should_not_proceed() -> TestResult {
//given