From 092b9606ff2b721d858a5c7b2b27a2f9942b4bc4 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 16 Jul 2025 10:10:41 +0100 Subject: chore: nix flake update required running: `cargo fix --allow-dirty --allow-staged` `cargo clippy --fix --allow-dirty -- -D warnings` to fix problems and then manually fixing some too --- src/lib/login/fresh.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/login') diff --git a/src/lib/login/fresh.rs b/src/lib/login/fresh.rs index 683d4af..a169177 100644 --- a/src/lib/login/fresh.rs +++ b/src/lib/login/fresh.rs @@ -278,7 +278,7 @@ pub async fn get_fresh_nip46_signer( let input = Interactor::default() .input( PromptInputParms::default().with_prompt(if let Some(error) = error { - format!("error: {}. try again with NIP-05 address", error) + format!("error: {error}. try again with NIP-05 address") } else { "NIP-05 address".to_string() }), @@ -296,7 +296,7 @@ pub async fn get_fresh_nip46_signer( let input = Interactor::default() .input( PromptInputParms::default().with_prompt(if let Some(error) = error { - format!("error: {}. try again with bunker url", error) + format!("error: {error}. try again with bunker url") } else { "bunker url".to_string() }), @@ -505,7 +505,7 @@ async fn save_to_git_config( if let Err(error) = silently_save_to_git_config(git_repo, signer_info, global).context(err_msg.clone()) { - eprintln!("Error: {:?}", error); + eprintln!("Error: {error:?}"); match signer_info { SignerInfo::Nsec { nsec, @@ -577,7 +577,7 @@ async fn save_to_git_config( ), ) { - eprintln!("Error: {:?}", error); + eprintln!("Error: {error:?}"); eprintln!("login details were not saved"); } else { eprintln!( -- cgit v1.2.3 From ac53bca7e315848864ff9e51703720b5b466bc42 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 16 Jul 2025 10:59:20 +0100 Subject: chore: bump nightly rustfmt to latest available and apply fmt fixes --- flake.nix | 2 +- src/bin/git_remote_nostr/push.rs | 36 ++-- src/bin/git_remote_nostr/utils.rs | 13 +- src/bin/ngit/sub_commands/list.rs | 13 +- src/bin/ngit/sub_commands/send.rs | 7 +- src/lib/client.rs | 132 +++++++------ src/lib/git/identify_ahead_behind.rs | 8 +- src/lib/git/mod.rs | 83 ++++---- src/lib/git_events.rs | 16 +- src/lib/login/mod.rs | 14 +- src/lib/repo_ref.rs | 13 +- src/lib/repo_state.rs | 7 +- test_utils/src/lib.rs | 204 +++++++++++-------- test_utils/src/relay.rs | 8 +- tests/git_remote_nostr/push.rs | 30 ++- tests/ngit_init.rs | 36 ++-- tests/ngit_list.rs | 366 +++++++++++++++++++++-------------- tests/ngit_login.rs | 350 +++++++++++++++++++-------------- tests/ngit_send.rs | 246 ++++++++++++++--------- 19 files changed, 951 insertions(+), 633 deletions(-) (limited to 'src/lib/login') diff --git a/flake.nix b/flake.nix index ff528e5..9ca8a7d 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ # ideally this wouldn't be pinned to a specific nightly version but # selectLatestNightlyWith isn't support with mixed toolchains # https://github.com/oxalica/rust-overlay/issues/136 - (lib.hiPrio rust-bin.nightly."2024-12-15".rustfmt) + (lib.hiPrio rust-bin.nightly."2025-07-16".rustfmt) # (rust-bin.stable.latest.override { extensions = [ "rust-analyzer" ]; }) rust-bin.stable.latest.default ]; diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 04fc4d8..9ff8af0 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -1049,10 +1049,13 @@ async fn get_merged_status_events( let (ahead, _) = git_repo.get_commits_ahead_behind(&tip_of_remote_branch, &tip_of_pushed_branch)?; - let commit_events = get_events_from_local_cache(git_repo.get_path()?, vec![ - nostr::Filter::default().kind(nostr::Kind::GitPatch), - // TODO: limit by repo_ref - ]) + let commit_events = get_events_from_local_cache( + git_repo.get_path()?, + vec![ + nostr::Filter::default().kind(nostr::Kind::GitPatch), + // TODO: limit by repo_ref + ], + ) .await?; let merged_proposals_info = @@ -1129,9 +1132,12 @@ async fn get_merged_proposals_info( proposals.entry(proposal_id).or_default(); // ignore revisions without all the merged commits if entry_revision_id == &revision_id { - merged_patches.insert(*commit_hash, MergedPRCommitType::PatchCommit { - event_id: patch_event.id, - }); + merged_patches.insert( + *commit_hash, + MergedPRCommitType::PatchCommit { + event_id: patch_event.id, + }, + ); } } } @@ -1156,9 +1162,12 @@ async fn get_merged_proposals_info( proposals.entry(proposal_id).or_default(); // ignore revisions without all the applied commits if entry_revision_id == &revision_id { - merged_patches.insert(*commit_hash, MergedPRCommitType::PatchApplied { - event_id: patch_event.id, - }); + merged_patches.insert( + *commit_hash, + MergedPRCommitType::PatchApplied { + event_id: patch_event.id, + }, + ); } } } @@ -1405,9 +1414,10 @@ async fn get_proposal_and_revision_root_from_patch( .clone(), )?; - get_events_from_local_cache(git_repo.get_path()?, vec![ - nostr::Filter::default().id(proposal_or_revision_id), - ]) + get_events_from_local_cache( + git_repo.get_path()?, + vec![nostr::Filter::default().id(proposal_or_revision_id)], + ) .await? .first() .unwrap() diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index f7e688e..dc75872 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs @@ -108,11 +108,14 @@ pub async fn get_open_or_draft_proposals( .collect(); let statuses: Vec = { - let mut statuses = get_events_from_local_cache(git_repo_path, vec![ - nostr::Filter::default() - .kinds(status_kinds().clone()) - .events(proposals.iter().map(|e| e.id)), - ]) + let mut statuses = get_events_from_local_cache( + git_repo_path, + vec![ + nostr::Filter::default() + .kinds(status_kinds().clone()) + .events(proposals.iter().map(|e| e.id)), + ], + ) .await?; statuses.sort_by_key(|e| e.created_at); statuses.reverse(); diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs index 2c91e66..0330be1 100644 --- a/src/bin/ngit/sub_commands/list.rs +++ b/src/bin/ngit/sub_commands/list.rs @@ -49,11 +49,14 @@ pub async fn launch() -> Result<()> { } let statuses: Vec = { - let mut statuses = get_events_from_local_cache(git_repo_path, vec![ - nostr::Filter::default() - .kinds(status_kinds().clone()) - .events(proposals_and_revisions.iter().map(|e| e.id)), - ]) + let mut statuses = get_events_from_local_cache( + git_repo_path, + vec![ + nostr::Filter::default() + .kinds(status_kinds().clone()) + .events(proposals_and_revisions.iter().map(|e| e.id)), + ], + ) .await?; statuses.sort_by_key(|e| e.created_at); statuses.reverse(); diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index 5a5acc8..c84e339 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs @@ -378,9 +378,10 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( public_key: _, uppercase: false, }) => { - let events = get_events_from_local_cache(git_repo_path, vec![ - nostr::Filter::new().id(*event_id), - ]) + let events = get_events_from_local_cache( + git_repo_path, + vec![nostr::Filter::new().id(*event_id)], + ) .await?; if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) { diff --git a/src/lib/client.rs b/src/lib/client.rs index 16cfe30..9253022 100644 --- a/src/lib/client.rs +++ b/src/lib/client.rs @@ -1103,16 +1103,18 @@ pub async fn get_state_from_cache( ) -> Result { if let Some(git_repo_path) = git_repo_path { RepoState::try_from( - get_events_from_local_cache(git_repo_path, vec![get_filter_state_events( - &repo_ref.coordinates(), - )]) + get_events_from_local_cache( + git_repo_path, + vec![get_filter_state_events(&repo_ref.coordinates())], + ) .await?, ) } else { RepoState::try_from( - get_event_from_global_cache(git_repo_path, vec![get_filter_state_events( - &repo_ref.coordinates(), - )]) + get_event_from_global_cache( + git_repo_path, + vec![get_filter_state_events(&repo_ref.coordinates())], + ) .await?, ) } @@ -1178,17 +1180,20 @@ async fn create_relays_request( } if let Some(git_repo_path) = git_repo_path { - for event in &get_events_from_local_cache(git_repo_path, vec![ - nostr::Filter::default() - .kinds(vec![Kind::GitPatch]) - .custom_tags( - SingleLetterTag::lowercase(nostr_sdk::Alphabet::A), - repo_coordinates_without_relays - .iter() - .map(|c| c.coordinate.to_string()) - .collect::>(), - ), - ]) + for event in &get_events_from_local_cache( + git_repo_path, + vec![ + nostr::Filter::default() + .kinds(vec![Kind::GitPatch]) + .custom_tags( + SingleLetterTag::lowercase(nostr_sdk::Alphabet::A), + repo_coordinates_without_relays + .iter() + .map(|c| c.coordinate.to_string()) + .collect::>(), + ), + ], + ) .await? { if event_is_patch_set_root(event) || event_is_revision_root(event) { @@ -1198,11 +1203,11 @@ async fn create_relays_request( } } - let profile_events = - get_event_from_global_cache(git_repo_path, vec![get_filter_contributor_profiles( - contributors.clone(), - )]) - .await?; + let profile_events = get_event_from_global_cache( + git_repo_path, + vec![get_filter_contributor_profiles(contributors.clone())], + ) + .await?; for c in &contributors { if let Some(event) = profile_events .iter() @@ -1768,17 +1773,20 @@ pub async fn get_proposals_and_revisions_from_cache( git_repo_path: &Path, repo_coordinates: HashSet, ) -> Result> { - let mut proposals = get_events_from_local_cache(git_repo_path, vec![ - nostr::Filter::default() - .kind(nostr::Kind::GitPatch) - .custom_tags( - nostr::SingleLetterTag::lowercase(nostr_sdk::Alphabet::A), - repo_coordinates - .iter() - .map(|c| c.coordinate.to_string()) - .collect::>(), - ), - ]) + let mut proposals = get_events_from_local_cache( + git_repo_path, + vec![ + nostr::Filter::default() + .kind(nostr::Kind::GitPatch) + .custom_tags( + nostr::SingleLetterTag::lowercase(nostr_sdk::Alphabet::A), + repo_coordinates + .iter() + .map(|c| c.coordinate.to_string()) + .collect::>(), + ), + ], + ) .await? .iter() .filter(|e| event_is_patch_set_root(e)) @@ -1794,23 +1802,29 @@ pub async fn get_all_proposal_patch_events_from_cache( repo_ref: &RepoRef, proposal_id: &nostr::EventId, ) -> Result> { - let mut commit_events = get_events_from_local_cache(git_repo_path, vec![ - nostr::Filter::default() - .kind(nostr::Kind::GitPatch) - .event(*proposal_id), - nostr::Filter::default() - .kind(nostr::Kind::GitPatch) - .id(*proposal_id), - ]) + let mut commit_events = get_events_from_local_cache( + git_repo_path, + vec![ + nostr::Filter::default() + .kind(nostr::Kind::GitPatch) + .event(*proposal_id), + nostr::Filter::default() + .kind(nostr::Kind::GitPatch) + .id(*proposal_id), + ], + ) .await?; - let permissioned_users: HashSet = [repo_ref.maintainers.clone(), vec![ - commit_events - .iter() - .find(|e| e.id.eq(proposal_id)) - .context("proposal not in cache")? - .pubkey, - ]] + let permissioned_users: HashSet = [ + repo_ref.maintainers.clone(), + vec![ + commit_events + .iter() + .find(|e| e.id.eq(proposal_id)) + .context("proposal not in cache")? + .pubkey, + ], + ] .concat() .iter() .copied() @@ -1824,12 +1838,15 @@ pub async fn get_all_proposal_patch_events_from_cache( .collect(); if !revision_roots.is_empty() { - for event in get_events_from_local_cache(git_repo_path, vec![ - nostr::Filter::default() - .kind(nostr::Kind::GitPatch) - .events(revision_roots) - .authors(permissioned_users.clone()), - ]) + for event in get_events_from_local_cache( + git_repo_path, + vec![ + nostr::Filter::default() + .kind(nostr::Kind::GitPatch) + .events(revision_roots) + .authors(permissioned_users.clone()), + ], + ) .await? { commit_events.push(event); @@ -1844,9 +1861,10 @@ pub async fn get_all_proposal_patch_events_from_cache( } pub async fn get_event_from_cache_by_id(git_repo: &Repo, event_id: &EventId) -> Result { - Ok(get_events_from_local_cache(git_repo.get_path()?, vec![ - nostr::Filter::default().id(*event_id), - ]) + Ok(get_events_from_local_cache( + git_repo.get_path()?, + vec![nostr::Filter::default().id(*event_id)], + ) .await? .first() .context("failed to find event in cache")? diff --git a/src/lib/git/identify_ahead_behind.rs b/src/lib/git/identify_ahead_behind.rs index baea687..d736522 100644 --- a/src/lib/git/identify_ahead_behind.rs +++ b/src/lib/git/identify_ahead_behind.rs @@ -184,10 +184,10 @@ mod tests { identify_ahead_behind(&git_repo, &Some("feature".to_string()), &None)?; assert_eq!(from_branch, "feature"); - assert_eq!(ahead, vec![ - oid_to_sha1(&feature_oid), - oid_to_sha1(&dev_oid_first) - ]); + assert_eq!( + ahead, + vec![oid_to_sha1(&feature_oid), oid_to_sha1(&dev_oid_first)] + ); assert_eq!(to_branch, "main"); assert_eq!(behind, vec![]); diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index 464990b..d4bf2f5 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs @@ -1490,10 +1490,10 @@ mod tests { &oid_to_sha1(&feature_oid), )?; assert_eq!(ahead, vec![]); - assert_eq!(behind, vec![ - oid_to_sha1(&behind_2_oid), - oid_to_sha1(&behind_1_oid), - ],); + assert_eq!( + behind, + vec![oid_to_sha1(&behind_2_oid), oid_to_sha1(&behind_1_oid),], + ); Ok(()) } @@ -1515,10 +1515,10 @@ mod tests { &oid_to_sha1(&main_oid), &oid_to_sha1(&ahead_2_oid), )?; - assert_eq!(ahead, vec![ - oid_to_sha1(&ahead_2_oid), - oid_to_sha1(&ahead_1_oid), - ],); + assert_eq!( + ahead, + vec![oid_to_sha1(&ahead_2_oid), oid_to_sha1(&ahead_1_oid),], + ); assert_eq!(behind, vec![]); Ok(()) } @@ -1547,14 +1547,14 @@ mod tests { &oid_to_sha1(&behind_2_oid), &oid_to_sha1(&ahead_2_oid), )?; - assert_eq!(ahead, vec![ - oid_to_sha1(&ahead_2_oid), - oid_to_sha1(&ahead_1_oid) - ],); - assert_eq!(behind, vec![ - oid_to_sha1(&behind_2_oid), - oid_to_sha1(&behind_1_oid) - ],); + assert_eq!( + ahead, + vec![oid_to_sha1(&ahead_2_oid), oid_to_sha1(&ahead_1_oid)], + ); + assert_eq!( + behind, + vec![oid_to_sha1(&behind_2_oid), oid_to_sha1(&behind_1_oid)], + ); Ok(()) } } @@ -2209,9 +2209,10 @@ mod tests { test_repo.populate_with_test_branch()?; test_repo.checkout("main")?; - assert_eq!(git_repo.parse_starting_commits("HEAD~1")?, vec![ - str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")? - ],); + assert_eq!( + git_repo.parse_starting_commits("HEAD~1")?, + vec![str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?], + ); Ok(()) } @@ -2221,9 +2222,10 @@ mod tests { let git_repo = Repo::from_path(&test_repo.dir)?; test_repo.populate_with_test_branch()?; - assert_eq!(git_repo.parse_starting_commits("HEAD~1")?, vec![ - str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")? - ],); + assert_eq!( + git_repo.parse_starting_commits("HEAD~1")?, + vec![str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")?], + ); Ok(()) } } @@ -2237,10 +2239,13 @@ mod tests { test_repo.populate_with_test_branch()?; test_repo.checkout("main")?; - assert_eq!(git_repo.parse_starting_commits("HEAD~2")?, vec![ - str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?, - str_to_sha1("af474d8d271490e5c635aad337abdc050034b16a")?, - ],); + assert_eq!( + git_repo.parse_starting_commits("HEAD~2")?, + vec![ + str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?, + str_to_sha1("af474d8d271490e5c635aad337abdc050034b16a")?, + ], + ); Ok(()) } } @@ -2253,11 +2258,14 @@ mod tests { let git_repo = Repo::from_path(&test_repo.dir)?; test_repo.populate_with_test_branch()?; - assert_eq!(git_repo.parse_starting_commits("HEAD~3")?, vec![ - str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")?, - str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?, - str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?, - ],); + assert_eq!( + git_repo.parse_starting_commits("HEAD~3")?, + vec![ + str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")?, + str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?, + str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?, + ], + ); Ok(()) } } @@ -2271,11 +2279,14 @@ mod tests { test_repo.populate_with_test_branch()?; test_repo.checkout("main")?; - assert_eq!(git_repo.parse_starting_commits("af474d8..a23e6b0")?, vec![ - str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?, - str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?, - str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?, - ],); + assert_eq!( + git_repo.parse_starting_commits("af474d8..a23e6b0")?, + vec![ + str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?, + str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?, + str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?, + ], + ); Ok(()) } } diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs index 3ce7637..69406c1 100644 --- a/src/lib/git_events.rs +++ b/src/lib/git_events.rs @@ -134,14 +134,15 @@ pub async fn generate_patch_event( // code that makes it into the main branch, assuming // the commit id is correct Tag::from_standardized(TagStandard::Reference(commit.to_string())), - Tag::custom(TagKind::Custom(std::borrow::Cow::Borrowed("alt")), vec![ - format!( + Tag::custom( + TagKind::Custom(std::borrow::Cow::Borrowed("alt")), + vec![format!( "git patch: {}", git_repo .get_commit_message_summary(commit) .unwrap_or_default() - ), - ]), + )], + ), ], if let Some(thread_event_id) = thread_event_id { vec![Tag::from_standardized(nostr_sdk::TagStandard::Event { @@ -205,9 +206,10 @@ pub async fn generate_patch_event( .collect(), vec![ // a fallback is now in place to extract this from the patch - Tag::custom(TagKind::Custom(std::borrow::Cow::Borrowed("commit")), vec![ - commit.to_string(), - ]), + Tag::custom( + TagKind::Custom(std::borrow::Cow::Borrowed("commit")), + vec![commit.to_string()], + ), // this is required as patches cannot be relied upon to include the 'base // commit' Tag::custom( diff --git a/src/lib/login/mod.rs b/src/lib/login/mod.rs index bfc7328..3fcd755 100644 --- a/src/lib/login/mod.rs +++ b/src/lib/login/mod.rs @@ -79,11 +79,15 @@ fn print_logged_in_as( "failed to find your relay list. consider using another nostr client to create one to enhance your nostr experience." ); } - eprintln!("logged in as {}{}", user_ref.metadata.name, match source { - SignerInfoSource::CommandLineArguments => " via cli arguments", - SignerInfoSource::GitLocal => " to local repository", - SignerInfoSource::GitGlobal => "", - }); + eprintln!( + "logged in as {}{}", + user_ref.metadata.name, + match source { + SignerInfoSource::CommandLineArguments => " via cli arguments", + SignerInfoSource::GitLocal => " to local repository", + SignerInfoSource::GitGlobal => "", + } + ); Ok(()) } diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs index c1fc288..0236e34 100644 --- a/src/lib/repo_ref.rs +++ b/src/lib/repo_ref.rs @@ -578,11 +578,14 @@ pub fn save_repo_config_to_yaml( .context("failed to convert public key into npub")?, ); } - serde_yaml::to_writer(file, &RepoConfigYaml { - identifier: Some(identifier), - maintainers: maintainers_npubs, - relays, - }) + serde_yaml::to_writer( + file, + &RepoConfigYaml { + identifier: Some(identifier), + maintainers: maintainers_npubs, + relays, + }, + ) .context("failed to write maintainers to maintainers.yaml file serde_yaml") } diff --git a/src/lib/repo_state.rs b/src/lib/repo_state.rs index 04f3cf2..345f05c 100644 --- a/src/lib/repo_state.rs +++ b/src/lib/repo_state.rs @@ -56,9 +56,10 @@ impl RepoState { add_head(&mut state); let mut tags = vec![Tag::identifier(identifier.clone())]; for (name, value) in &state { - tags.push(Tag::custom(nostr_sdk::TagKind::Custom(name.into()), vec![ - value.clone(), - ])); + tags.push(Tag::custom( + nostr_sdk::TagKind::Custom(name.into()), + vec![value.clone()], + )); } let event = sign_event( EventBuilder::new(STATE_KIND, "").tags(tags), diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 1312610..7d79cff 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -544,10 +544,14 @@ impl CliTesterConfirmPrompt<'_> { let mut s = String::new(); self.tester .formatter - .format_confirm_prompt_selection(&mut s, self.prompt.as_str(), match input { - None => self.default, - Some(_) => input, - }) + .format_confirm_prompt_selection( + &mut s, + self.prompt.as_str(), + match input { + None => self.default, + Some(_) => input, + }, + ) .expect("diagluer theme formatter should succeed"); if !s.contains(self.prompt.as_str()) { panic!("dialoguer must be broken as formatted prompt success doesnt contain prompt"); @@ -1017,10 +1021,13 @@ where cmd.env("RUST_BACKTRACE", "0"); cmd.args(args); // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes - rexpect::session::spawn_with_options(cmd, Options { - timeout_ms: Some(timeout_ms), - strip_ansi_escape_codes: true, - }) + rexpect::session::spawn_with_options( + cmd, + Options { + timeout_ms: Some(timeout_ms), + strip_ansi_escape_codes: true, + }, + ) } pub fn rexpect_with_from_dir( @@ -1038,10 +1045,13 @@ where cmd.current_dir(dir); cmd.args(args); // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes - rexpect::session::spawn_with_options(cmd, Options { - timeout_ms: Some(timeout_ms), - strip_ansi_escape_codes: true, - }) + rexpect::session::spawn_with_options( + cmd, + Options { + timeout_ms: Some(timeout_ms), + strip_ansi_escape_codes: true, + }, + ) } pub fn remote_helper_rexpect_with_from_dir( @@ -1056,10 +1066,13 @@ pub fn remote_helper_rexpect_with_from_dir( cmd.current_dir(dir); cmd.args([dir.as_os_str().to_str().unwrap(), nostr_remote_url]); // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes - rexpect::session::spawn_with_options(cmd, Options { - timeout_ms: Some(timeout_ms), - strip_ansi_escape_codes: true, - }) + rexpect::session::spawn_with_options( + cmd, + Options { + timeout_ms: Some(timeout_ms), + strip_ansi_escape_codes: true, + }, + ) } pub fn git_with_remote_helper_rexpect_with_from_dir( @@ -1103,10 +1116,13 @@ where cmd.current_dir(dir); cmd.args(args); // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes - rexpect::session::spawn_with_options(cmd, Options { - timeout_ms: Some(timeout_ms), - strip_ansi_escape_codes: true, - }) + rexpect::session::spawn_with_options( + cmd, + Options { + timeout_ms: Some(timeout_ms), + strip_ansi_escape_codes: true, + }, + ) .context("spawning failed") } @@ -1145,11 +1161,14 @@ pub fn get_proposal_branch_name( test_repo: &GitTestRepo, branch_name_in_event: &str, ) -> Result { - let events = block_on(get_events_from_cache(&test_repo.dir, vec![ - nostr::Filter::default() - .kind(nostr_sdk::Kind::GitPatch) - .hashtag("root"), - ]))?; + let events = block_on(get_events_from_cache( + &test_repo.dir, + vec![ + nostr::Filter::default() + .kind(nostr_sdk::Kind::GitPatch) + .hashtag("root"), + ], + ))?; get_proposal_branch_name_from_events(&events, branch_name_in_event) } @@ -1303,45 +1322,54 @@ pub fn cli_tester_create_proposal( create_and_populate_branch(test_repo, branch_name, prefix, false, None)?; std::thread::sleep(std::time::Duration::from_millis(1000)); if let Some(in_reply_to) = in_reply_to { - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "--nsec", - TEST_KEY_1_NSEC, - "--password", - TEST_PASSWORD, - "--disable-cli-spinners", - "send", - "HEAD~2", - "--no-cover-letter", - "--in-reply-to", - in_reply_to.as_str(), - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + [ + "--nsec", + TEST_KEY_1_NSEC, + "--password", + TEST_PASSWORD, + "--disable-cli-spinners", + "send", + "HEAD~2", + "--no-cover-letter", + "--in-reply-to", + in_reply_to.as_str(), + ], + ); p.expect_end_eventually()?; } else if let Some((title, description)) = cover_letter_title_and_description { - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "--nsec", - TEST_KEY_1_NSEC, - "--password", - TEST_PASSWORD, - "--disable-cli-spinners", - "send", - "HEAD~2", - "--title", - format!("\"{title}\"").as_str(), - "--description", - format!("\"{description}\"").as_str(), - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + [ + "--nsec", + TEST_KEY_1_NSEC, + "--password", + TEST_PASSWORD, + "--disable-cli-spinners", + "send", + "HEAD~2", + "--title", + format!("\"{title}\"").as_str(), + "--description", + format!("\"{description}\"").as_str(), + ], + ); p.expect_end_eventually()?; } else { - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "--nsec", - TEST_KEY_1_NSEC, - "--password", - TEST_PASSWORD, - "--disable-cli-spinners", - "send", - "HEAD~2", - "--no-cover-letter", - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + [ + "--nsec", + TEST_KEY_1_NSEC, + "--password", + TEST_PASSWORD, + "--disable-cli-spinners", + "send", + "HEAD~2", + "--no-cover-letter", + ], + ); p.expect_end_eventually()?; } Ok(()) @@ -1373,11 +1401,14 @@ pub fn use_ngit_list_to_download_and_checkout_proposal_branch( let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with( if proposal_number == 3 { 0 @@ -1389,12 +1420,15 @@ pub fn use_ngit_list_to_download_and_checkout_proposal_branch( true, None, )?; - let mut c = p.expect_choice("", vec![ - format!("create and checkout proposal branch (2 ahead 0 behind 'main')"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("create and checkout proposal branch (2 ahead 0 behind 'main')"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect_end_eventually()?; Ok(()) @@ -1466,9 +1500,10 @@ fn get_first_proposal_event_id() -> Result { client.fetch_events( nostr::Filter::default() .kind(nostr::Kind::GitPatch) - .custom_tags(nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), vec![ - "root", - ]), + .custom_tags( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), Duration::from_millis(500), ), )? @@ -1496,15 +1531,18 @@ pub fn create_proposals_with_first_revised_and_repo_with_unrevised_proposal_chec amend_last_commit(&originating_repo, "add some ammended-commit.md")?; - let mut p = CliTester::new_from_dir(&originating_repo.dir, [ - "--nsec", - TEST_KEY_1_NSEC, - "--password", - TEST_PASSWORD, - "--disable-cli-spinners", - "push", - "--force", - ]); + let mut p = CliTester::new_from_dir( + &originating_repo.dir, + [ + "--nsec", + TEST_KEY_1_NSEC, + "--password", + TEST_PASSWORD, + "--disable-cli-spinners", + "push", + "--force", + ], + ); p.expect_end_eventually()?; Ok((originating_repo, test_repo)) diff --git a/test_utils/src/relay.rs b/test_utils/src/relay.rs index 14778d9..b14f532 100644 --- a/test_utils/src/relay.rs +++ b/test_utils/src/relay.rs @@ -161,9 +161,11 @@ impl<'a> Relay<'a> { if let Some(listner) = self.req_listener { listner(self, client_id, subscription_id, vec![filter.clone()])?; } else { - self.respond_standard_req(client_id, &subscription_id, &[ - filter.clone() - ])?; + self.respond_standard_req( + client_id, + &subscription_id, + &[filter.clone()], + )?; // self.respond_eose(client_id, subscription_id)?; } // respond with events diff --git a/tests/git_remote_nostr/push.rs b/tests/git_remote_nostr/push.rs index 9f5f492..5912543 100644 --- a/tests/git_remote_nostr/push.rs +++ b/tests/git_remote_nostr/push.rs @@ -969,12 +969,10 @@ async fn proposal_three_way_merge_commit_pushed_to_main_leads_to_status_event_is std::fs::write(git_repo.dir.join("new.md"), "some content")?; git_repo.stage_and_commit("new.md")?; - CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, [ - "merge", - &branch_name, - "-m", - "proposal merge commit message", - ]) + CliTester::new_git_with_remote_helper_from_dir( + &git_repo.dir, + ["merge", &branch_name, "-m", "proposal merge commit message"], + ) .expect_end_eventually_and_print()?; let oid = git_repo.get_tip_of_local_branch("main")?; @@ -1125,12 +1123,10 @@ async fn proposal_fast_forward_merge_commits_pushed_to_main_leads_to_status_even git_repo.checkout_remote_branch(&branch_name)?; git_repo.checkout("refs/heads/main")?; - CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, [ - "merge", - &branch_name, - "-m", - "proposal merge commit message", - ]) + CliTester::new_git_with_remote_helper_from_dir( + &git_repo.dir, + ["merge", &branch_name, "-m", "proposal merge commit message"], + ) .expect_end_eventually_and_print()?; let oid = git_repo.get_tip_of_local_branch("main")?; @@ -1784,12 +1780,10 @@ async fn push_new_pr_branch_creates_proposal() -> Result<()> { std::fs::write(git_repo.dir.join("new2.md"), "some content")?; git_repo.stage_and_commit("new2.md")?; - let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, [ - "push", - "-u", - "origin", - branch_name, - ]); + let mut p = CliTester::new_git_with_remote_helper_from_dir( + &git_repo.dir, + ["push", "-u", "origin", branch_name], + ); cli_expect_nostr_fetch(&mut p)?; p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; p.expect("list: connecting...\r\n\r\r\r")?; diff --git a/tests/ngit_init.rs b/tests/ngit_init.rs index e49dbdd..1a23177 100644 --- a/tests/ngit_init.rs +++ b/tests/ngit_init.rs @@ -75,10 +75,14 @@ mod when_repo_not_previously_claimed { 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -197,10 +201,14 @@ mod when_repo_not_previously_claimed { 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -454,10 +462,14 @@ mod when_repo_not_previously_claimed { 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), diff --git a/tests/ngit_list.rs b/tests/ngit_list.rs index c8f761a..0547ad4 100644 --- a/tests/ngit_list.rs +++ b/tests/ngit_list.rs @@ -201,11 +201,14 @@ mod when_main_branch_is_uptodate { p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; let mut c = p.expect_choice("", vec![ format!( @@ -317,11 +320,14 @@ mod when_main_branch_is_uptodate { p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(0, true, None)?; let mut c = p.expect_choice("", vec![ format!( @@ -436,12 +442,15 @@ mod when_main_branch_is_uptodate { p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("add d3.md"), // commit msg title - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("add d3.md"), // commit msg title + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(0, true, None)?; let mut c = p.expect_choice("", vec![ format!( @@ -511,12 +520,15 @@ mod when_main_branch_is_uptodate { p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("add d3.md"), // commit msg title - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("add d3.md"), // commit msg title + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(0, true, None)?; let mut c = p.expect_choice("", vec![ format!( @@ -630,11 +642,14 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; let mut c = p.expect_choice("", vec![ format!( @@ -652,18 +667,24 @@ mod when_main_branch_is_uptodate { p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; - let mut c = p.expect_choice("", vec![ - format!("checkout proposal branch (2 ahead 0 behind 'main')"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout proposal branch (2 ahead 0 behind 'main')"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect_end_eventually_and_print()?; @@ -717,11 +738,14 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; let mut c = p.expect_choice("", vec![ format!( @@ -739,18 +763,24 @@ mod when_main_branch_is_uptodate { p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; - let mut c = p.expect_choice("", vec![ - format!("checkout proposal branch (2 ahead 0 behind 'main')"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout proposal branch (2 ahead 0 behind 'main')"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect(format!( "checked out proposal as 'pr/{FEATURE_BRANCH_NAME_1}(", @@ -823,18 +853,24 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; - let mut c = p.expect_choice("", vec![ - format!("checkout proposal branch and apply 1 appendments"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout proposal branch and apply 1 appendments"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect("checked out proposal branch and applied 1 appendments (2 ahead 0 behind 'main')\r\n")?; p.expect_end()?; @@ -893,18 +929,24 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; - let mut c = p.expect_choice("", vec![ - format!("checkout proposal branch and apply 1 appendments"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout proposal branch and apply 1 appendments"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect("checked out proposal branch and applied 1 appendments (2 ahead 0 behind 'main')\r\n")?; p.expect_end()?; @@ -1000,21 +1042,29 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; p.expect_eventually("--force`\r\n")?; - let mut c = p.expect_choice("", vec![ - format!("checkout local branch with unpublished changes"), - format!("discard unpublished changes and checkout new revision"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - "back".to_string(), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout local branch with unpublished changes"), + format!( + "discard unpublished changes and checkout new revision" + ), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + "back".to_string(), + ], + )?; c.succeeds_with(1, true, Some(0))?; p.expect_end_eventually_and_print()?; @@ -1071,11 +1121,14 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; p.expect("you have an amended/rebase version the proposal that is unpublished\r\n")?; p.expect("you have previously applied the latest version of the proposal (2 ahead 0 behind 'main') but your local proposal branch has amended or rebased it (2 ahead 0 behind 'main')\r\n")?; @@ -1084,13 +1137,18 @@ mod when_main_branch_is_uptodate { p.expect(" 2) run `ngit list` and checkout the latest published version of this proposal\r\n")?; p.expect("if you are confident in your changes consider running `ngit push --force`\r\n")?; - let mut c = p.expect_choice("", vec![ - format!("checkout local branch with unpublished changes"), - format!("discard unpublished changes and checkout new revision"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - "back".to_string(), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout local branch with unpublished changes"), + format!( + "discard unpublished changes and checkout new revision" + ), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + "back".to_string(), + ], + )?; c.succeeds_with(1, true, Some(1))?; p.expect_end_with("checked out latest version of proposal (2 ahead 0 behind 'main'), replacing unpublished version (2 ahead 0 behind 'main')\r\n")?; @@ -1168,20 +1226,26 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; p.expect( "local proposal branch exists with 1 unpublished commits on top of the most up-to-date version of the proposal (3 ahead 0 behind 'main')\r\n", )?; - let mut c = p.expect_choice("", vec![ - format!("checkout proposal branch with 1 unpublished commits"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout proposal branch with 1 unpublished commits"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect("checked out proposal branch with 1 unpublished commits (3 ahead 0 behind 'main')\r\n")?; p.expect_end()?; @@ -1244,20 +1308,26 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; p.expect( "local proposal branch exists with 1 unpublished commits on top of the most up-to-date version of the proposal (3 ahead 0 behind 'main')\r\n", )?; - let mut c = p.expect_choice("", vec![ - format!("checkout proposal branch with 1 unpublished commits"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout proposal branch with 1 unpublished commits"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect("checked out proposal branch with 1 unpublished commits (3 ahead 0 behind 'main')\r\n")?; p.expect_end()?; @@ -1340,20 +1410,26 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; - let mut c = p.expect_choice("", vec![ - format!("checkout and overwrite existing proposal branch"), - format!("checkout existing outdated proposal branch"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout and overwrite existing proposal branch"), + format!("checkout existing outdated proposal branch"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; p.expect_end()?; @@ -1407,20 +1483,26 @@ mod when_main_branch_is_uptodate { let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // some updates listed here - let mut c = p.expect_choice("all proposals", vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ])?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; c.succeeds_with(2, true, None)?; p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; - let mut c = p.expect_choice("", vec![ - format!("checkout and overwrite existing proposal branch"), - format!("checkout existing outdated proposal branch"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ])?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout and overwrite existing proposal branch"), + format!("checkout existing outdated proposal branch"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; c.succeeds_with(0, true, Some(0))?; p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; p.expect_end()?; diff --git a/tests/ngit_login.rs b/tests/ngit_login.rs index 09e40f1..9e708dc 100644 --- a/tests/ngit_login.rs +++ b/tests/ngit_login.rs @@ -6,21 +6,27 @@ use test_utils::*; static EXPECTED_NSEC_PROMPT: &str = "nsec"; fn show_first_time_login_choices(p: &mut CliTester) -> Result { - p.expect_choice("login to nostr", vec![ - "secret key (nsec / ncryptsec)".to_string(), - "nostr connect (remote signer)".to_string(), - "create account".to_string(), - "help".to_string(), - ]) + p.expect_choice( + "login to nostr", + vec![ + "secret key (nsec / ncryptsec)".to_string(), + "nostr connect (remote signer)".to_string(), + "create account".to_string(), + "help".to_string(), + ], + ) } fn first_time_login_choices_succeeds_with_nsec(p: &mut CliTester, nsec: &str) -> Result<()> { - p.expect_choice("login to nostr", vec![ - "secret key (nsec / ncryptsec)".to_string(), - "nostr connect (remote signer)".to_string(), - "create account".to_string(), - "help".to_string(), - ])? + p.expect_choice( + "login to nostr", + vec![ + "secret key (nsec / ncryptsec)".to_string(), + "nostr connect (remote signer)".to_string(), + "create account".to_string(), + "help".to_string(), + ], + )? .succeeds_with(0, false, Some(0))?; p.expect_input(EXPECTED_NSEC_PROMPT)? @@ -129,17 +135,25 @@ mod with_relays { async fn when_latest_metadata_and_relay_list_on_all_relays() -> Result<()> { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), ) @@ -154,14 +168,18 @@ mod with_relays { async fn when_metadata_contains_only_display_name() -> Result<()> { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - nostr::event::EventBuilder::metadata( - &nostr::Metadata::new().display_name("fred"), - ) - .sign_with_keys(&TEST_KEY_1_KEYS) - .unwrap(), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + nostr::event::EventBuilder::metadata( + &nostr::Metadata::new().display_name("fred"), + ) + .sign_with_keys(&TEST_KEY_1_KEYS) + .unwrap(), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), None, @@ -187,14 +205,19 @@ mod with_relays { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - nostr::event::EventBuilder::metadata( - &nostr::Metadata::new().custom_field("displayName", "fred"), - ) - .sign_with_keys(&TEST_KEY_1_KEYS) - .unwrap(), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + nostr::event::EventBuilder::metadata( + &nostr::Metadata::new() + .custom_field("displayName", "fred"), + ) + .sign_with_keys(&TEST_KEY_1_KEYS) + .unwrap(), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), None, @@ -208,14 +231,18 @@ mod with_relays { -> Result<()> { run_test_displays_fallback_to_npub( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - nostr::event::EventBuilder::metadata( - &nostr::Metadata::new().about("other info in metadata"), - ) - .sign_with_keys(&TEST_KEY_1_KEYS) - .unwrap(), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + nostr::event::EventBuilder::metadata( + &nostr::Metadata::new().about("other info in metadata"), + ) + .sign_with_keys(&TEST_KEY_1_KEYS) + .unwrap(), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), None, @@ -230,10 +257,14 @@ mod with_relays { -> Result<()> { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), None, @@ -247,15 +278,19 @@ mod with_relays { { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_test_key_1_metadata_event("fred")], + )?; Ok(()) }), Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_test_key_1_relay_list_event_same_as_fallback()], + )?; Ok(()) }), ) @@ -267,16 +302,22 @@ mod with_relays { async fn when_some_relays_return_old_metadata_event() -> Result<()> { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event_old("fred old"), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_test_key_1_metadata_event_old("fred old")], + )?; Ok(()) }), ) @@ -288,16 +329,22 @@ mod with_relays { async fn when_some_relays_return_other_users_metadata() -> Result<()> { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_2_metadata_event("carole"), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_test_key_2_metadata_event("carole")], + )?; Ok(()) }), Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event_old("fred"), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event_old("fred"), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), ) @@ -310,16 +357,22 @@ mod with_relays { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { let event = generate_test_key_1_kind_event(nostr::Kind::TextNote); - relay.respond_events(client_id, &subscription_id, &vec![ - make_event_old_or_change_user(event, &TEST_KEY_1_KEYS, 0), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![make_event_old_or_change_user(event, &TEST_KEY_1_KEYS, 0)], + )?; Ok(()) }), Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event_old("fred"), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event_old("fred"), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), ) @@ -334,10 +387,14 @@ mod with_relays { async fn displays_correct_name() -> Result<()> { run_test_when_specifying_command_line_nsec_only_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event_same_as_fallback(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event_same_as_fallback(), + ], + )?; Ok(()) }), None, @@ -355,12 +412,10 @@ mod with_relays { let cli_tester_handle = std::thread::spawn(move || -> Result<()> { let test_repo = GitTestRepo::default(); - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "account", - "login", - "--nsec", - TEST_KEY_1_NSEC, - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + ["account", "login", "--nsec", TEST_KEY_1_NSEC], + ); p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; @@ -432,9 +487,11 @@ mod with_relays { async fn warm_user_and_displays_name() -> Result<()> { run_test_when_no_relay_list_found_warns_user_and_uses_npub( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_test_key_1_metadata_event("fred")], + )?; Ok(()) }), None, @@ -525,17 +582,25 @@ mod with_relays { async fn displays_correct_name() -> Result<()> { run_test_displays_correct_name( Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event_old("Fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event_old("Fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ) @@ -607,10 +672,10 @@ mod with_offline_flag { true, )?; - p.expect_choice("login to nostr", vec![ - "try again with nsec".to_string(), - "back".to_string(), - ])? + p.expect_choice( + "login to nostr", + vec!["try again with nsec".to_string(), "back".to_string()], + )? .succeeds_with(0, false, Some(0))?; } @@ -630,13 +695,10 @@ mod with_offline_flag { #[test] fn valid_nsec_param_succeeds_without_prompts() -> Result<()> { let test_repo = GitTestRepo::default(); - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "account", - "login", - "--offline", - "--nsec", - TEST_KEY_1_NSEC, - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + ["account", "login", "--offline", "--nsec", TEST_KEY_1_NSEC], + ); p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; @@ -648,13 +710,10 @@ mod with_offline_flag { #[test] fn invalid_nsec_param_fails_without_prompts() -> Result<()> { let test_repo = GitTestRepo::default(); - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "account", - "login", - "--offline", - "--nsec", - TEST_INVALID_NSEC, - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + ["account", "login", "--offline", "--nsec", TEST_INVALID_NSEC], + ); p.expect_end_with( "Error: invalid nsec parameter\r\n\r\nCaused by:\r\n Invalid secret key\r\n", @@ -668,15 +727,18 @@ mod with_offline_flag { #[test] fn valid_nsec_param_succeeds_without_prompts() -> Result<()> { let test_repo = GitTestRepo::default(); - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "account", - "login", - "--offline", - "--nsec", - TEST_KEY_1_NSEC, - "--password", - TEST_PASSWORD, - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + [ + "account", + "login", + "--offline", + "--nsec", + TEST_KEY_1_NSEC, + "--password", + TEST_PASSWORD, + ], + ); p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; p.expect_end_with( @@ -687,15 +749,18 @@ mod with_offline_flag { #[test] fn parameters_can_be_called_globally() -> Result<()> { let test_repo = GitTestRepo::default(); - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "--nsec", - TEST_KEY_1_NSEC, - "--password", - TEST_PASSWORD, - "account", - "login", - "--offline", - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + [ + "--nsec", + TEST_KEY_1_NSEC, + "--password", + TEST_PASSWORD, + "account", + "login", + "--offline", + ], + ); p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; p.expect_end_with( @@ -710,15 +775,18 @@ mod with_offline_flag { fn valid_nsec_param_succeeds_without_prompts_and_logs_in() -> Result<()> { standard_first_time_login_with_nsec()?.exit()?; let test_repo = GitTestRepo::default(); - let mut p = CliTester::new_from_dir(&test_repo.dir, [ - "account", - "login", - "--offline", - "--nsec", - TEST_KEY_2_NSEC, - "--password", - TEST_PASSWORD, - ]); + let mut p = CliTester::new_from_dir( + &test_repo.dir, + [ + "account", + "login", + "--offline", + "--nsec", + TEST_KEY_2_NSEC, + "--password", + TEST_PASSWORD, + ], + ); p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; p.expect_end_with( diff --git a/tests/ngit_send.rs b/tests/ngit_send.rs index 5cc5291..2cd5956 100644 --- a/tests/ngit_send.rs +++ b/tests/ngit_send.rs @@ -181,10 +181,14 @@ async fn prep_run_create_proposal( 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -194,9 +198,11 @@ async fn prep_run_create_proposal( 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), @@ -762,10 +768,14 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -775,9 +785,11 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), @@ -836,10 +848,14 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -849,9 +865,11 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), @@ -904,10 +922,14 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -917,9 +939,11 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), @@ -992,10 +1016,14 @@ mod when_no_cover_letter_flag_set_with_range_of_head_2_sends_2_patches_without_c 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -1005,9 +1033,11 @@ mod when_no_cover_letter_flag_set_with_range_of_head_2_sends_2_patches_without_c 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), @@ -1174,13 +1204,16 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { fn expect_msgs_first(p: &mut CliTester) -> Result<()> { p.expect("fetching updates...\r\n")?; p.expect_eventually("\r\n")?; // may be 'no updates' or some updates - let mut selector = p.expect_multi_select("select commits for proposal", vec![ - "(Joe Bloggs) add t4.md [feature] fe973a8".to_string(), - "(Joe Bloggs) add t3.md 232efb3".to_string(), - "(Joe Bloggs) add t2.md [main] 431b84e".to_string(), - "(Joe Bloggs) add t1.md af474d8".to_string(), - "(Joe Bloggs) Initial commit 9ee507f".to_string(), - ])?; + let mut selector = p.expect_multi_select( + "select commits for proposal", + vec![ + "(Joe Bloggs) add t4.md [feature] fe973a8".to_string(), + "(Joe Bloggs) add t3.md 232efb3".to_string(), + "(Joe Bloggs) add t2.md [main] 431b84e".to_string(), + "(Joe Bloggs) add t1.md af474d8".to_string(), + "(Joe Bloggs) Initial commit 9ee507f".to_string(), + ], + )?; selector.succeeds_with(vec![0, 1], false, vec![0, 1])?; p.expect("creating proposal from 2 commits:\r\n")?; p.expect("fe973a8 add t4.md\r\n")?; @@ -1205,10 +1238,14 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -1218,9 +1255,11 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), @@ -1262,10 +1301,14 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -1275,9 +1318,11 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), @@ -1393,11 +1438,15 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - get_pretend_proposal_root_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + get_pretend_proposal_root_event(), + ], + )?; Ok(()) }), ), @@ -1407,10 +1456,11 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - get_pretend_proposal_root_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event(), get_pretend_proposal_root_event()], + )?; Ok(()) }), ), @@ -1451,11 +1501,15 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - get_pretend_proposal_root_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + get_pretend_proposal_root_event(), + ], + )?; Ok(()) }), ), @@ -1465,10 +1519,11 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - get_pretend_proposal_root_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event(), get_pretend_proposal_root_event()], + )?; Ok(()) }), ), @@ -1645,11 +1700,15 @@ mod in_reply_to_mentions_issue { 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - get_pretend_issue_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + get_pretend_issue_event(), + ], + )?; Ok(()) }), ), @@ -1659,10 +1718,11 @@ mod in_reply_to_mentions_issue { 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - get_pretend_issue_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event(), get_pretend_issue_event()], + )?; Ok(()) }), ), @@ -1764,10 +1824,14 @@ mod in_reply_to_mentions_npub_and_nprofile_which_get_mentioned_in_proposal_root 8051, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_test_key_1_metadata_event("fred"), - generate_test_key_1_relay_list_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![ + generate_test_key_1_metadata_event("fred"), + generate_test_key_1_relay_list_event(), + ], + )?; Ok(()) }), ), @@ -1777,9 +1841,11 @@ mod in_reply_to_mentions_npub_and_nprofile_which_get_mentioned_in_proposal_root 8055, None, Some(&|relay, client_id, subscription_id, _| -> Result<()> { - relay.respond_events(client_id, &subscription_id, &vec![ - generate_repo_ref_event(), - ])?; + relay.respond_events( + client_id, + &subscription_id, + &vec![generate_repo_ref_event()], + )?; Ok(()) }), ), -- cgit v1.2.3