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");
|
||||
self.open_repository.replace(repository);
|
||||
if self.repo_details.repo_config.is_none() {
|
||||
tracing::debug!("Handler: CloneRepo: Sending: LoadConfigFromRepo");
|
||||
actor::logger(&self.log, "send: LoadConfigFromRepo");
|
||||
ctx.address().do_send(actor::messages::LoadConfigFromRepo);
|
||||
actor::do_send(
|
||||
ctx.address(),
|
||||
actor::messages::LoadConfigFromRepo,
|
||||
&self.log,
|
||||
);
|
||||
} else {
|
||||
tracing::debug!("Handler: CloneRepo: Sending: 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);
|
||||
|
||||
// load config from repo
|
||||
let (load_config_from_repo_open_repository, read_files) =
|
||||
given::open_repository_for_loading_config_from_repo(&repo_config);
|
||||
let branches = repo_config.branches().clone();
|
||||
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);
|
||||
|
||||
// handles_validate_repo_message(&mut open_repository, repo_config.branches());
|
||||
|
||||
let mut repository_factory = MockRepositoryFactory::new();
|
||||
expect::open_repository(&mut repository_factory, open_repository);
|
||||
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();
|
||||
|
||||
//then
|
||||
tracing::debug!("{read_files:#?}");
|
||||
let file_name = PathBuf::from(".git-next.toml".to_string());
|
||||
read_files
|
||||
.lock()
|
||||
.map_err(|e| e.to_string())
|
||||
.map(|files| assert_eq!(files.clone(), vec![(branch, file_name)]))?;
|
||||
load_file_log.require_message_containing("read_file:branch:file")?;
|
||||
// tracing::debug!("{read_files:#?}");
|
||||
// let file_name = PathBuf::from(".git-next.toml".to_string());
|
||||
// read_files
|
||||
// .lock()
|
||||
// .map_err(|e| e.to_string())
|
||||
// .map(|files| assert_eq!(files.clone(), vec![(branch, file_name)]))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue