From 4ee83e2fe5335a8afd78439c35f029c4a472e797 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 16 Dec 2024 09:00:46 +0000 Subject: chore: bump nix flake rust nightly `fmt` overlay update the rust nightly `fmt` overlay which needs to be pinned to a specific version (this case by date) update formatting in main files via `cargo fmt` --- tests/git_remote_nostr/main.rs | 2 +- tests/git_remote_nostr/push.rs | 30 ++- tests/ngit_init.rs | 36 +-- tests/ngit_list.rs | 488 +++++++++++++++++------------------------ tests/ngit_login.rs | 352 ++++++++++++----------------- tests/ngit_send.rs | 246 ++++++++------------- 6 files changed, 460 insertions(+), 694 deletions(-) (limited to 'tests') diff --git a/tests/git_remote_nostr/main.rs b/tests/git_remote_nostr/main.rs index 5a1d416..686a5df 100644 --- a/tests/git_remote_nostr/main.rs +++ b/tests/git_remote_nostr/main.rs @@ -4,7 +4,7 @@ use anyhow::{Context, Result}; use futures::join; use git2::Oid; use nostr::nips::nip01::Coordinate; -use nostr_sdk::{secp256k1::rand, Event, JsonUtil, Kind, RelayUrl, ToBech32}; +use nostr_sdk::{Event, JsonUtil, Kind, RelayUrl, ToBech32, secp256k1::rand}; use relay::Relay; use serial_test::serial; use test_utils::{git::GitTestRepo, *}; diff --git a/tests/git_remote_nostr/push.rs b/tests/git_remote_nostr/push.rs index 30602c9..4e44642 100644 --- a/tests/git_remote_nostr/push.rs +++ b/tests/git_remote_nostr/push.rs @@ -925,10 +925,12 @@ 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")?; @@ -1079,10 +1081,12 @@ 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")?; @@ -1736,10 +1740,12 @@ 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 {} ref list over filesystem...\r\n", source_path).as_str())?; p.expect("list: connecting...\r\n\r\r\r")?; diff --git a/tests/ngit_init.rs b/tests/ngit_init.rs index da4091f..4b61559 100644 --- a/tests/ngit_init.rs +++ b/tests/ngit_init.rs @@ -84,14 +84,10 @@ 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(()) }), ), @@ -211,14 +207,10 @@ 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(()) }), ), @@ -471,14 +463,10 @@ 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 1d297b6..4a3aad5 100644 --- a/tests/ngit_list.rs +++ b/tests/ngit_list.rs @@ -49,7 +49,7 @@ async fn prep_proposals_repo_and_repo_with_proposal_pulled_and_checkedout( mod cannot_find_repo_event { use super::*; mod cli_prompts { - use nostr::{nips::nip01::Coordinate, ToBech32}; + use nostr::{ToBech32, nips::nip01::Coordinate}; use nostr_sdk::RelayUrl; use super::*; @@ -196,25 +196,20 @@ 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!( - "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, None)?; p.expect(format!( "checked out proposal as 'pr/{}(", @@ -318,25 +313,20 @@ 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!( - "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(format!( "checked out proposal as 'pr/{}(", @@ -427,8 +417,8 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_metadata_event("fred")); r55.events.push(generate_test_key_1_relay_list_event()); - let cli_tester_handle = std::thread::spawn( - move || -> Result<(GitTestRepo, GitTestRepo)> { + let cli_tester_handle = + std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { let originating_repo = cli_tester_create_proposals()?; cli_tester_create_proposal( &originating_repo, @@ -443,26 +433,21 @@ 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!( - "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_and_print()?; @@ -470,8 +455,7 @@ mod when_main_branch_is_uptodate { relay::shutdown_relay(8000 + p)?; } Ok((originating_repo, test_repo)) - }, - ); + }); // launch relay let _ = join!( @@ -524,26 +508,21 @@ 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!( - "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(format!( "checked out proposal as 'pr/{}(", @@ -639,8 +618,8 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_metadata_event("fred")); r55.events.push(generate_test_key_1_relay_list_event()); - let cli_tester_handle = std::thread::spawn( - move || -> Result<(GitTestRepo, GitTestRepo)> { + let cli_tester_handle = + std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); @@ -649,24 +628,20 @@ 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!("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()?; @@ -675,24 +650,18 @@ 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()?; @@ -700,8 +669,7 @@ mod when_main_branch_is_uptodate { relay::shutdown_relay(8000 + p)?; } Ok((originating_repo, test_repo)) - }, - ); + }); // launch relay let _ = join!( @@ -747,24 +715,20 @@ 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!("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()?; @@ -773,24 +737,18 @@ 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/{}(", @@ -864,24 +822,18 @@ 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()?; @@ -940,24 +892,18 @@ 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()?; @@ -1053,29 +999,21 @@ 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()?; @@ -1132,14 +1070,11 @@ 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")?; @@ -1148,18 +1083,13 @@ 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")?; @@ -1237,26 +1167,20 @@ 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()?; @@ -1319,26 +1243,20 @@ 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()?; @@ -1421,26 +1339,20 @@ 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()?; @@ -1494,26 +1406,20 @@ 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 78a160c..b1e2676 100644 --- a/tests/ngit_login.rs +++ b/tests/ngit_login.rs @@ -6,27 +6,21 @@ 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)? @@ -49,7 +43,7 @@ fn standard_first_time_login_with_nsec() -> Result { mod with_relays { use anyhow::Ok; use futures::join; - use test_utils::relay::{shutdown_relay, ListenerReqFunc, Relay}; + use test_utils::relay::{ListenerReqFunc, Relay, shutdown_relay}; use super::*; @@ -137,25 +131,17 @@ 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(()) }), ) @@ -170,18 +156,14 @@ 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, @@ -207,19 +189,14 @@ 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, @@ -233,18 +210,14 @@ 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, @@ -259,14 +232,10 @@ 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, @@ -280,19 +249,15 @@ 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(()) }), ) @@ -304,22 +269,16 @@ 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(()) }), ) @@ -331,22 +290,16 @@ 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(()) }), ) @@ -359,22 +312,16 @@ 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(()) }), ) @@ -389,14 +336,10 @@ 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, @@ -414,10 +357,12 @@ 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")?; @@ -489,11 +434,9 @@ 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, @@ -584,25 +527,17 @@ 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(()) }), ) @@ -674,10 +609,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))?; } @@ -697,10 +632,13 @@ 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")?; @@ -712,10 +650,13 @@ 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", @@ -729,18 +670,15 @@ 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( @@ -751,18 +689,15 @@ 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( @@ -777,18 +712,15 @@ 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 1ffb515..d728d9c 100644 --- a/tests/ngit_send.rs +++ b/tests/ngit_send.rs @@ -181,14 +181,10 @@ 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(()) }), ), @@ -198,11 +194,9 @@ 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(()) }), ), @@ -764,14 +758,10 @@ 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(()) }), ), @@ -781,11 +771,9 @@ 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(()) }), ), @@ -844,14 +832,10 @@ 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(()) }), ), @@ -861,11 +845,9 @@ 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(()) }), ), @@ -918,14 +900,10 @@ 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(()) }), ), @@ -935,11 +913,9 @@ 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(()) }), ), @@ -1012,14 +988,10 @@ 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(()) }), ), @@ -1029,11 +1001,9 @@ 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(()) }), ), @@ -1200,16 +1170,13 @@ 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")?; @@ -1234,14 +1201,10 @@ 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(()) }), ), @@ -1251,11 +1214,9 @@ 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(()) }), ), @@ -1297,14 +1258,10 @@ 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(()) }), ), @@ -1314,11 +1271,9 @@ 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(()) }), ), @@ -1435,15 +1390,11 @@ 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(()) }), ), @@ -1453,11 +1404,10 @@ 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(()) }), ), @@ -1498,15 +1448,11 @@ 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(()) }), ), @@ -1516,11 +1462,10 @@ 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(()) }), ), @@ -1697,15 +1642,11 @@ 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(()) }), ), @@ -1715,11 +1656,10 @@ 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(()) }), ), @@ -1821,14 +1761,10 @@ 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(()) }), ), @@ -1838,11 +1774,9 @@ 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