Compare commits
2 commits
0796df00d4
...
975c9e315c
Author | SHA1 | Date | |
---|---|---|---|
975c9e315c | |||
880fa0cc0e |
4 changed files with 57 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ stateDiagram-v2
|
|||
|
||||
CloneRepo --> LoadConfigFromRepo :on repo config
|
||||
CloneRepo --> ValidateRepo :on server config
|
||||
CloneRepo --> RegisterWebhook :on server config
|
||||
|
||||
LoadConfigFromRepo --> ReceiveRepoConfig
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue