WIP: refactor: CloneRepo use actor::do_send to send LoadConfigFromRepo
This commit is contained in:
parent
f038ab508b
commit
46ceceec46
2 changed files with 38 additions and 13 deletions
|
@ -20,9 +20,11 @@ impl Handler<actor::messages::CloneRepo> for actor::RepoActor {
|
||||||
tracing::debug!("open okay");
|
tracing::debug!("open okay");
|
||||||
self.open_repository.replace(repository);
|
self.open_repository.replace(repository);
|
||||||
if self.repo_details.repo_config.is_none() {
|
if self.repo_details.repo_config.is_none() {
|
||||||
tracing::debug!("Handler: CloneRepo: Sending: LoadConfigFromRepo");
|
actor::do_send(
|
||||||
actor::logger(&self.log, "send: LoadConfigFromRepo");
|
ctx.address(),
|
||||||
ctx.address().do_send(actor::messages::LoadConfigFromRepo);
|
actor::messages::LoadConfigFromRepo,
|
||||||
|
&self.log,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!("Handler: CloneRepo: Sending: ValidateRepo");
|
tracing::debug!("Handler: CloneRepo: Sending: ValidateRepo");
|
||||||
actor::logger(&self.log, "send: ValidateRepo");
|
actor::logger(&self.log, "send: ValidateRepo");
|
||||||
|
|
|
@ -91,12 +91,34 @@ async fn when_server_has_no_repo_config_load_from_repo_and_validate() -> TestRes
|
||||||
given::has_all_valid_remote_defaults(&mut open_repository, &repo_details);
|
given::has_all_valid_remote_defaults(&mut open_repository, &repo_details);
|
||||||
|
|
||||||
// load config from repo
|
// load config from repo
|
||||||
let (load_config_from_repo_open_repository, read_files) =
|
let branches = repo_config.branches().clone();
|
||||||
given::open_repository_for_loading_config_from_repo(&repo_config);
|
let mut load_config_from_repo_open_repository = MockOpenRepositoryLike::new();
|
||||||
|
let load_file_log = RepoActorLog::default();
|
||||||
|
let load_file_log_ref = Some(load_file_log.clone());
|
||||||
|
load_config_from_repo_open_repository
|
||||||
|
.expect_read_file()
|
||||||
|
.return_once(move |branch_name, file_name| {
|
||||||
|
let branch_name = branch_name.clone();
|
||||||
|
let file_name = file_name.to_path_buf();
|
||||||
|
actor::logger(
|
||||||
|
&load_file_log_ref,
|
||||||
|
format!("read_file:${branch_name}:${file_name:?}"),
|
||||||
|
);
|
||||||
|
let contents = format!(
|
||||||
|
r#"
|
||||||
|
[branches]
|
||||||
|
main = "{}"
|
||||||
|
next = "{}"
|
||||||
|
dev = "{}"
|
||||||
|
"#,
|
||||||
|
branches.main(),
|
||||||
|
branches.next(),
|
||||||
|
branches.dev()
|
||||||
|
);
|
||||||
|
Ok(contents)
|
||||||
|
});
|
||||||
expect::duplicate(&mut open_repository, load_config_from_repo_open_repository);
|
expect::duplicate(&mut open_repository, load_config_from_repo_open_repository);
|
||||||
|
|
||||||
// handles_validate_repo_message(&mut open_repository, repo_config.branches());
|
|
||||||
|
|
||||||
let mut repository_factory = MockRepositoryFactory::new();
|
let mut repository_factory = MockRepositoryFactory::new();
|
||||||
expect::open_repository(&mut repository_factory, open_repository);
|
expect::open_repository(&mut repository_factory, open_repository);
|
||||||
fs.dir_create(&repo_details.gitdir)?;
|
fs.dir_create(&repo_details.gitdir)?;
|
||||||
|
@ -108,12 +130,13 @@ async fn when_server_has_no_repo_config_load_from_repo_and_validate() -> TestRes
|
||||||
System::current().stop();
|
System::current().stop();
|
||||||
|
|
||||||
//then
|
//then
|
||||||
tracing::debug!("{read_files:#?}");
|
load_file_log.require_message_containing("read_file:branch:file")?;
|
||||||
let file_name = PathBuf::from(".git-next.toml".to_string());
|
// tracing::debug!("{read_files:#?}");
|
||||||
read_files
|
// let file_name = PathBuf::from(".git-next.toml".to_string());
|
||||||
.lock()
|
// read_files
|
||||||
.map_err(|e| e.to_string())
|
// .lock()
|
||||||
.map(|files| assert_eq!(files.clone(), vec![(branch, file_name)]))?;
|
// .map_err(|e| e.to_string())
|
||||||
|
// .map(|files| assert_eq!(files.clone(), vec![(branch, file_name)]))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue