From 82c7a95f6e9aa266d2f0d2035a0ce4f1715b62ad Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 13 Nov 2025 17:18:35 +0000 Subject: feat(list): make list async and include sync report inline copy relay fetching approach to async and reporting --- tests/git_remote_nostr/list.rs | 29 ++++++++--------------------- tests/git_remote_nostr/push.rs | 30 ++++++++++++------------------ 2 files changed, 20 insertions(+), 39 deletions(-) (limited to 'tests') diff --git a/tests/git_remote_nostr/list.rs b/tests/git_remote_nostr/list.rs index 8723b54..88bd3f7 100644 --- a/tests/git_remote_nostr/list.rs +++ b/tests/git_remote_nostr/list.rs @@ -8,7 +8,7 @@ mod without_state_announcement { #[serial] async fn lists_head_and_2_branches_and_commit_ids_from_git_server() -> Result<()> { let source_git_repo = prep_git_repo()?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); std::fs::write(source_git_repo.dir.join("commit.md"), "some content")?; let main_commit_id = source_git_repo.stage_and_commit("commit.md")?; @@ -41,8 +41,7 @@ mod without_state_announcement { let cli_tester_handle = std::thread::spawn(move || -> Result<()> { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; - p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; - p.expect("list: connecting...\r\n\r")?; + p.expect("git servers: listing refs...\r\n")?; // println!("{}", p.expect_eventually("\r\n\r\n")?); let res = p.expect_eventually("\r\n\r\n")?; p.exit()?; @@ -90,7 +89,7 @@ mod with_state_announcement { #[serial] async fn lists_head_and_2_branches_and_commit_ids_announcement() -> Result<()> { let (state_event, source_git_repo) = generate_repo_with_state_event().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?; let example_commit_id = source_git_repo.get_tip_of_local_branch("example-branch")?; @@ -119,10 +118,7 @@ mod with_state_announcement { let cli_tester_handle = std::thread::spawn(move || -> Result<()> { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; - p.expect( - format!("fetching {source_path} ref list over filesystem...\r\n").as_str(), - )?; - p.expect("list: connecting...\r\n\r")?; + p.expect("git servers: listing refs...\r\n")?; // println!("{}", p.expect_eventually("\r\n\r\n")?); let res = p.expect_eventually("\r\n\r\n")?; p.exit()?; @@ -163,7 +159,7 @@ mod with_state_announcement { #[serial] async fn anouncement_state_is_used() -> Result<()> { let (state_event, source_git_repo) = generate_repo_with_state_event().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let main_original_commit_id = source_git_repo.get_tip_of_local_branch("main")?; { @@ -203,13 +199,7 @@ mod with_state_announcement { let cli_tester_handle = std::thread::spawn(move || -> Result<()> { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; - p.expect( - format!("fetching {source_path} ref list over filesystem...\r\n").as_str(), - )?; - p.expect("list: connecting...\r\n\r")?; - p.expect( - format!("WARNING: {source_path} is out of sync. main out of sync\r\n").as_str(), - )?; + p.expect("git servers: listing refs...\r\n")?; // println!("{}", p.expect_eventually("\r\n\r\n")?); let res = p.expect_eventually("\r\n\r\n")?; @@ -255,7 +245,7 @@ mod with_state_announcement { #[serial] async fn open_proposal_listed_in_prs_namespace() -> Result<()> { let (state_event, source_git_repo) = generate_repo_with_state_event().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let main_commit_id = source_git_repo.get_tip_of_local_branch("main")?; let example_commit_id = source_git_repo.get_tip_of_local_branch("example-branch")?; @@ -287,10 +277,7 @@ mod with_state_announcement { let mut p = cli_tester_after_fetch(&git_repo)?; p.send_line("list")?; - p.expect( - format!("fetching {source_path} ref list over filesystem...\r\n").as_str(), - )?; - p.expect("list: connecting...\r\n\r")?; + p.expect("git servers: listing refs...\r\n")?; // println!("{}", p.expect_eventually("\r\n\r\n")?); let res = p.expect_eventually("\r\n\r\n")?; diff --git a/tests/git_remote_nostr/push.rs b/tests/git_remote_nostr/push.rs index 647a2f3..404d07f 100644 --- a/tests/git_remote_nostr/push.rs +++ b/tests/git_remote_nostr/push.rs @@ -845,7 +845,7 @@ async fn pushes_to_all_git_servers_listed_and_ok_printed() -> Result<()> { async fn proposal_three_way_merge_commit_pushed_to_main_leads_to_status_event_issued() -> Result<()> { let (events, source_git_repo) = prep_source_repo_and_events_including_proposals().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( Relay::new(8051, None, None), @@ -881,8 +881,7 @@ async fn proposal_three_way_merge_commit_pushed_to_main_leads_to_status_event_is let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); 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")?; + p.expect("git servers: listing refs...\r\n")?; p.expect_eventually("merge commit ")?; // shorthand merge commit id appears in this gap p.expect_eventually(": create nostr proposal status event\r\n")?; @@ -1002,7 +1001,7 @@ async fn proposal_fast_forward_merge_commits_pushed_to_main_leads_to_status_even -> Result<()> { // let (events, source_git_repo) = prep_source_repo_and_events_including_proposals().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( Relay::new(8051, None, None), @@ -1035,8 +1034,7 @@ async fn proposal_fast_forward_merge_commits_pushed_to_main_leads_to_status_even let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); 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")?; + p.expect("git servers: listing refs...\r\n")?; p.expect_eventually(format!( "fast-forward merge: create nostr proposal status event for {branch_name}\r\n" ))?; @@ -1184,7 +1182,7 @@ async fn proposal_fast_forward_merge_commits_pushed_to_main_leads_to_status_even async fn proposal_commits_applied_and_pushed_to_main_leads_to_status_event_issued() -> Result<()> { // let (events, source_git_repo) = prep_source_repo_and_events_including_proposals().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( Relay::new(8051, None, None), Relay::new(8052, None, None), @@ -1222,8 +1220,7 @@ async fn proposal_commits_applied_and_pushed_to_main_leads_to_status_event_issue let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); 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")?; + p.expect("git servers: listing refs...\r\n")?; p.expect_eventually(format!( "applied commits from proposal: create nostr proposal status event for {branch_name}\r\n" ))?; // status updates printed here @@ -1354,7 +1351,7 @@ async fn proposal_commits_applied_and_pushed_to_main_leads_to_status_event_issue #[serial] async fn push_2_commits_to_existing_proposal() -> Result<()> { let (events, source_git_repo) = prep_source_repo_and_events_including_proposals().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( Relay::new(8051, None, None), @@ -1384,8 +1381,7 @@ async fn push_2_commits_to_existing_proposal() -> Result<()> { let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); 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")?; + p.expect("git servers: listing refs...\r\n")?; p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; let output = p.expect_end_eventually()?; @@ -1500,7 +1496,7 @@ async fn push_2_commits_to_existing_proposal() -> Result<()> { #[serial] async fn force_push_creates_proposal_revision() -> Result<()> { let (events, source_git_repo) = prep_source_repo_and_events_including_proposals().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( Relay::new(8051, None, None), @@ -1539,8 +1535,7 @@ async fn force_push_creates_proposal_revision() -> Result<()> { let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push", "--force"]); 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")?; + p.expect("git servers: listing refs...\r\n")?; p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; let output = p.expect_end_eventually()?; @@ -1659,7 +1654,7 @@ async fn force_push_creates_proposal_revision() -> Result<()> { #[serial] async fn push_new_pr_branch_creates_proposal() -> Result<()> { let (events, source_git_repo) = prep_source_repo_and_events_including_proposals().await?; - let source_path = source_git_repo.dir.to_str().unwrap().to_string(); + let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( Relay::new(8051, None, None), @@ -1693,8 +1688,7 @@ async fn push_new_pr_branch_creates_proposal() -> Result<()> { ["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")?; + p.expect("git servers: listing refs...\r\n")?; p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; let output = p.expect_end_eventually()?; -- cgit v1.2.3