diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-19 20:38:00 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-19 20:38:00 +0100 |
| commit | ab1214060a7a2d55068a7ccc9c7f6a04fd7d5aa2 (patch) | |
| tree | e561bcc093d393c2d7056a6d6c5f52e886eead27 | |
| parent | 2e54dd09a1a3b42903eee00adf4472d8b679dcb1 (diff) | |
feat: intergrate `fetch` into `send`
reworking the tests and test suite as appropriate
| -rw-r--r-- | src/client.rs | 31 | ||||
| -rw-r--r-- | src/repo_ref.rs | 6 | ||||
| -rw-r--r-- | src/sub_commands/fetch.rs | 13 | ||||
| -rw-r--r-- | src/sub_commands/send.rs | 55 | ||||
| -rw-r--r-- | test_utils/src/git.rs | 26 | ||||
| -rw-r--r-- | test_utils/src/lib.rs | 2 | ||||
| -rw-r--r-- | tests/init.rs | 2 | ||||
| -rw-r--r-- | tests/send.rs | 24 |
8 files changed, 95 insertions, 64 deletions
diff --git a/src/client.rs b/src/client.rs index ccd5cfb..3b18ad8 100644 --- a/src/client.rs +++ b/src/client.rs | |||
| @@ -517,7 +517,13 @@ impl Connect for Client { | |||
| 517 | fresh_profiles = HashSet::new(); | 517 | fresh_profiles = HashSet::new(); |
| 518 | 518 | ||
| 519 | let relay = self.client.relay(&relay_url).await?; | 519 | let relay = self.client.relay(&relay_url).await?; |
| 520 | let events: Vec<nostr::Event> = get_events_of(&relay, filters, &None).await?; | 520 | let events: Vec<nostr::Event> = get_events_of(&relay, filters.clone(), &None) |
| 521 | .await? | ||
| 522 | .iter() | ||
| 523 | // don't process events that don't match filters | ||
| 524 | .filter(|e| filters.iter().any(|f| f.match_event(e))) | ||
| 525 | .cloned() | ||
| 526 | .collect(); | ||
| 521 | // TODO: try reconcile | 527 | // TODO: try reconcile |
| 522 | 528 | ||
| 523 | process_fetched_events( | 529 | process_fetched_events( |
| @@ -1363,3 +1369,26 @@ pub struct FetchRequest { | |||
| 1363 | profiles_to_fetch_from_user_relays: HashMap<PublicKey, (Timestamp, Timestamp)>, | 1369 | profiles_to_fetch_from_user_relays: HashMap<PublicKey, (Timestamp, Timestamp)>, |
| 1364 | user_relays_for_profiles: HashSet<Url>, | 1370 | user_relays_for_profiles: HashSet<Url>, |
| 1365 | } | 1371 | } |
| 1372 | |||
| 1373 | pub async fn fetching_with_report( | ||
| 1374 | git_repo_path: &Path, | ||
| 1375 | #[cfg(test)] client: &crate::client::MockConnect, | ||
| 1376 | #[cfg(not(test))] client: &Client, | ||
| 1377 | repo_coordinates: &HashSet<Coordinate>, | ||
| 1378 | ) -> Result<FetchReport> { | ||
| 1379 | let term = console::Term::stderr(); | ||
| 1380 | term.write_line("fetching updates...")?; | ||
| 1381 | let (relay_reports, progress_reporter) = client | ||
| 1382 | .fetch_all(git_repo_path, repo_coordinates, &HashSet::new()) | ||
| 1383 | .await?; | ||
| 1384 | if !relay_reports.iter().any(std::result::Result::is_err) { | ||
| 1385 | let _ = progress_reporter.clear(); | ||
| 1386 | } | ||
| 1387 | let report = consolidate_fetch_reports(relay_reports); | ||
| 1388 | if report.to_string().is_empty() { | ||
| 1389 | println!("no updates"); | ||
| 1390 | } else { | ||
| 1391 | println!("updates: {report}"); | ||
| 1392 | } | ||
| 1393 | Ok(report) | ||
| 1394 | } | ||
diff --git a/src/repo_ref.rs b/src/repo_ref.rs index 9bc3201..3e1fd22 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs | |||
| @@ -313,14 +313,14 @@ pub async fn get_repo_coordinates( | |||
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | fn ask_for_naddr() -> Result<Coordinate> { | 315 | fn ask_for_naddr() -> Result<Coordinate> { |
| 316 | let mut prompt = "repository naddr"; | ||
| 317 | Ok(loop { | 316 | Ok(loop { |
| 318 | if let Ok(c) = Coordinate::parse( | 317 | if let Ok(c) = Coordinate::parse( |
| 319 | Interactor::default().input(PromptInputParms::default().with_prompt(prompt))?, | 318 | Interactor::default() |
| 319 | .input(PromptInputParms::default().with_prompt("repository naddr"))?, | ||
| 320 | ) { | 320 | ) { |
| 321 | break c; | 321 | break c; |
| 322 | } | 322 | } |
| 323 | prompt = "repository valid naddr"; | 323 | println!("not a valid naddr"); |
| 324 | }) | 324 | }) |
| 325 | } | 325 | } |
| 326 | 326 | ||
diff --git a/src/sub_commands/fetch.rs b/src/sub_commands/fetch.rs index 28eb960..ab6e0fc 100644 --- a/src/sub_commands/fetch.rs +++ b/src/sub_commands/fetch.rs | |||
| @@ -9,7 +9,7 @@ use crate::client::Client; | |||
| 9 | #[cfg(test)] | 9 | #[cfg(test)] |
| 10 | use crate::client::MockConnect; | 10 | use crate::client::MockConnect; |
| 11 | use crate::{ | 11 | use crate::{ |
| 12 | client::{consolidate_fetch_reports, Connect}, | 12 | client::{fetching_with_report, Connect}, |
| 13 | git::{Repo, RepoActions}, | 13 | git::{Repo, RepoActions}, |
| 14 | repo_ref::get_repo_coordinates, | 14 | repo_ref::get_repo_coordinates, |
| 15 | Cli, | 15 | Cli, |
| @@ -38,16 +38,7 @@ pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | |||
| 38 | } | 38 | } |
| 39 | repo_coordinates | 39 | repo_coordinates |
| 40 | }; | 40 | }; |
| 41 | println!("fetching updates..."); | 41 | fetching_with_report(git_repo.get_path()?, &client, &repo_coordinates).await?; |
| 42 | let (relay_reports, _) = client | ||
| 43 | .fetch_all(git_repo.get_path()?, &repo_coordinates, &HashSet::new()) | ||
| 44 | .await?; | ||
| 45 | let report = consolidate_fetch_reports(relay_reports); | ||
| 46 | if report.to_string().is_empty() { | ||
| 47 | println!("no updates"); | ||
| 48 | } else { | ||
| 49 | println!("updates: {report}"); | ||
| 50 | } | ||
| 51 | client.disconnect().await?; | 42 | client.disconnect().await?; |
| 52 | Ok(()) | 43 | Ok(()) |
| 53 | } | 44 | } |
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 410e119..a289def 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use std::{str::FromStr, time::Duration}; | 1 | use std::{path::Path, str::FromStr, time::Duration}; |
| 2 | 2 | ||
| 3 | use anyhow::{bail, Context, Result}; | 3 | use anyhow::{bail, Context, Result}; |
| 4 | use console::Style; | 4 | use console::Style; |
| @@ -19,10 +19,12 @@ use crate::{ | |||
| 19 | cli_interactor::{ | 19 | cli_interactor::{ |
| 20 | Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms, PromptMultiChoiceParms, | 20 | Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms, PromptMultiChoiceParms, |
| 21 | }, | 21 | }, |
| 22 | client::{sign_event, Connect}, | 22 | client::{ |
| 23 | fetching_with_report, get_events_from_cache, get_repo_ref_from_cache, sign_event, Connect, | ||
| 24 | }, | ||
| 23 | git::{Repo, RepoActions}, | 25 | git::{Repo, RepoActions}, |
| 24 | login, | 26 | login, |
| 25 | repo_ref::{self, RepoRef, REPO_REF_KIND}, | 27 | repo_ref::{get_repo_coordinates, RepoRef, REPO_REF_KIND}, |
| 26 | Cli, | 28 | Cli, |
| 27 | }; | 29 | }; |
| 28 | 30 | ||
| @@ -49,6 +51,7 @@ pub struct SubCommandArgs { | |||
| 49 | #[allow(clippy::too_many_lines)] | 51 | #[allow(clippy::too_many_lines)] |
| 50 | pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | 52 | pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { |
| 51 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 53 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 54 | let git_repo_path = git_repo.get_path()?; | ||
| 52 | 55 | ||
| 53 | let (main_branch_name, main_tip) = git_repo | 56 | let (main_branch_name, main_tip) = git_repo |
| 54 | .get_main_or_master_branch() | 57 | .get_main_or_master_branch() |
| @@ -59,13 +62,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 59 | #[cfg(test)] | 62 | #[cfg(test)] |
| 60 | let mut client = <MockConnect as std::default::Default>::default(); | 63 | let mut client = <MockConnect as std::default::Default>::default(); |
| 61 | 64 | ||
| 62 | let (root_proposal_id, mention_tags) = get_root_proposal_id_and_mentions_from_in_reply_to( | 65 | let repo_coordinates = get_repo_coordinates(&git_repo, &client).await?; |
| 63 | &client, | 66 | |
| 64 | // TODO: user repo relays when when event cache is in place | 67 | fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; |
| 65 | client.get_fallback_relays(), | 68 | |
| 66 | &args.in_reply_to, | 69 | let (root_proposal_id, mention_tags) = |
| 67 | ) | 70 | get_root_proposal_id_and_mentions_from_in_reply_to(git_repo.get_path()?, &args.in_reply_to) |
| 68 | .await?; | 71 | .await?; |
| 69 | 72 | ||
| 70 | if let Some(root_ref) = args.in_reply_to.first() { | 73 | if let Some(root_ref) = args.in_reply_to.first() { |
| 71 | if root_proposal_id.is_some() { | 74 | if root_proposal_id.is_some() { |
| @@ -191,17 +194,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 191 | 194 | ||
| 192 | client.set_signer(signer.clone()).await; | 195 | client.set_signer(signer.clone()).await; |
| 193 | 196 | ||
| 194 | let repo_ref = repo_ref::fetch( | 197 | let repo_ref = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?; |
| 195 | &git_repo, | ||
| 196 | git_repo | ||
| 197 | .get_root_commit() | ||
| 198 | .context("failed to get root commit of the repository")? | ||
| 199 | .to_string(), | ||
| 200 | &client, | ||
| 201 | user_ref.relays.write(), | ||
| 202 | true, | ||
| 203 | ) | ||
| 204 | .await?; | ||
| 205 | 198 | ||
| 206 | // oldest first | 199 | // oldest first |
| 207 | commits.reverse(); | 200 | commits.reverse(); |
| @@ -520,9 +513,7 @@ fn summarise_commit_for_selection(git_repo: &Repo, commit: &Sha1Hash) -> Result< | |||
| 520 | } | 513 | } |
| 521 | 514 | ||
| 522 | async fn get_root_proposal_id_and_mentions_from_in_reply_to( | 515 | async fn get_root_proposal_id_and_mentions_from_in_reply_to( |
| 523 | #[cfg(test)] client: &crate::client::MockConnect, | 516 | git_repo_path: &Path, |
| 524 | #[cfg(not(test))] client: &Client, | ||
| 525 | repo_relays: &[String], | ||
| 526 | in_reply_to: &[String], | 517 | in_reply_to: &[String], |
| 527 | ) -> Result<(Option<String>, Vec<nostr::Tag>)> { | 518 | ) -> Result<(Option<String>, Vec<nostr::Tag>)> { |
| 528 | let root_proposal_id = if let Some(first) = in_reply_to.first() { | 519 | let root_proposal_id = if let Some(first) = in_reply_to.first() { |
| @@ -535,13 +526,10 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( | |||
| 535 | marker: _, | 526 | marker: _, |
| 536 | public_key: _, | 527 | public_key: _, |
| 537 | }) => { | 528 | }) => { |
| 538 | let events = client | 529 | let events = |
| 539 | .get_events( | 530 | get_events_from_cache(git_repo_path, vec![nostr::Filter::new().id(*event_id)]) |
| 540 | repo_relays.to_vec(), | 531 | .await?; |
| 541 | vec![nostr::Filter::new().id(*event_id)], | 532 | |
| 542 | ) | ||
| 543 | .await | ||
| 544 | .context("whilst getting events specified in --in-reply-to")?; | ||
| 545 | if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) { | 533 | if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) { |
| 546 | if event_is_patch_set_root(first) { | 534 | if event_is_patch_set_root(first) { |
| 547 | Some(event_id.to_string()) | 535 | Some(event_id.to_string()) |
| @@ -549,10 +537,7 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( | |||
| 549 | None | 537 | None |
| 550 | } | 538 | } |
| 551 | } else { | 539 | } else { |
| 552 | bail!( | 540 | None |
| 553 | "cannot find first event specified in --in-reply-to \"{}\"", | ||
| 554 | first, | ||
| 555 | ) | ||
| 556 | } | 541 | } |
| 557 | } | 542 | } |
| 558 | _ => None, | 543 | _ => None, |
diff --git a/test_utils/src/git.rs b/test_utils/src/git.rs index db50165..7aa7e84 100644 --- a/test_utils/src/git.rs +++ b/test_utils/src/git.rs | |||
| @@ -5,6 +5,10 @@ use std::{env::current_dir, fs, path::PathBuf}; | |||
| 5 | 5 | ||
| 6 | use anyhow::{Context, Result}; | 6 | use anyhow::{Context, Result}; |
| 7 | use git2::{Oid, RepositoryInitOptions, Signature, Time}; | 7 | use git2::{Oid, RepositoryInitOptions, Signature, Time}; |
| 8 | use nostr::nips::nip01::Coordinate; | ||
| 9 | use nostr_sdk::{Kind, ToBech32}; | ||
| 10 | |||
| 11 | use crate::{generate_repo_ref_event, REPOSITORY_KIND}; | ||
| 8 | 12 | ||
| 9 | pub struct GitTestRepo { | 13 | pub struct GitTestRepo { |
| 10 | pub dir: PathBuf, | 14 | pub dir: PathBuf, |
| @@ -13,7 +17,24 @@ pub struct GitTestRepo { | |||
| 13 | 17 | ||
| 14 | impl Default for GitTestRepo { | 18 | impl Default for GitTestRepo { |
| 15 | fn default() -> Self { | 19 | fn default() -> Self { |
| 16 | Self::new("main").unwrap() | 20 | let repo_event = generate_repo_ref_event(); |
| 21 | let coordinate = Coordinate { | ||
| 22 | kind: Kind::Custom(REPOSITORY_KIND), | ||
| 23 | public_key: repo_event.author(), | ||
| 24 | identifier: repo_event.identifier().unwrap().to_string(), | ||
| 25 | relays: vec![ | ||
| 26 | "ws://localhost:8055".to_string(), | ||
| 27 | "ws://localhost:8056".to_string(), | ||
| 28 | ], | ||
| 29 | }; | ||
| 30 | |||
| 31 | let repo = Self::new("main").unwrap(); | ||
| 32 | let _ = repo | ||
| 33 | .git_repo | ||
| 34 | .config() | ||
| 35 | .unwrap() | ||
| 36 | .set_str("nostr.repo", &coordinate.to_bech32().unwrap()); | ||
| 37 | repo | ||
| 17 | } | 38 | } |
| 18 | } | 39 | } |
| 19 | impl GitTestRepo { | 40 | impl GitTestRepo { |
| @@ -33,6 +54,9 @@ impl GitTestRepo { | |||
| 33 | git_repo, | 54 | git_repo, |
| 34 | }) | 55 | }) |
| 35 | } | 56 | } |
| 57 | pub fn without_repo_in_git_config() -> Self { | ||
| 58 | Self::new("main").unwrap() | ||
| 59 | } | ||
| 36 | 60 | ||
| 37 | pub fn initial_commit(&self) -> Result<Oid> { | 61 | pub fn initial_commit(&self) -> Result<Oid> { |
| 38 | let oid = self.git_repo.index()?.write_tree()?; | 62 | let oid = self.git_repo.index()?.write_tree()?; |
diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 2825eaa..a3ffd70 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs | |||
| @@ -191,7 +191,7 @@ pub fn generate_repo_ref_event() -> nostr::Event { | |||
| 191 | 191 | ||
| 192 | /// enough to fool event_is_patch_set_root | 192 | /// enough to fool event_is_patch_set_root |
| 193 | pub fn get_pretend_proposal_root_event() -> nostr::Event { | 193 | pub fn get_pretend_proposal_root_event() -> nostr::Event { |
| 194 | serde_json::from_str(r#"{"id":"8cb75aa4cda10a3a0f3242dc49d36159d30b3185bf63414cf6ce17f5c14a73b1","pubkey":"f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768","created_at":1714984571,"kind":1617,"tags":[["t","root"]],"content":"","sig":"6c197314b8c4c61da696dff888198333004d1ecc5d7bae2c554857f2f2b0d3ecc09369a5d8ba089c1bf89e3c6f5be40ade873fd698438ef8b303ffc6df35eb3f"}"#).unwrap() | 194 | serde_json::from_str(r#"{"id":"431e58eb8e1b4e20292d1d5bbe81d5cfb042e1bc165de32eddfdd52245a4cce4","pubkey":"f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768","created_at":1721404213,"kind":1617,"tags":[["a","30617:ba882566eff14f3baa976103998c452d27fe95b65a796a6a9f92628bced76fe5:9ee507fc4357d7ee16a5d8901bedcd103f23c17d-consider-it-random"],["a","30617:f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768:9ee507fc4357d7ee16a5d8901bedcd103f23c17d-consider-it-random"],["r","9ee507fc4357d7ee16a5d8901bedcd103f23c17d"],["t","cover-letter"],["alt","git patch cover letter: exampletitle"],["t","root"],["e","8cb75aa4cda10a3a0f3242dc49d36159d30b3185bf63414cf6ce17f5c14a73b1","","mention"],["branch-name","feature"],["p","ba882566eff14f3baa976103998c452d27fe95b65a796a6a9f92628bced76fe5"],["p","f53e4bcd7a9cdef049cf6467d638a1321958acd3b71eb09823fd6fadb023d768"]],"content":"From fe973a840fba2a8ab37dd505c154854a69a6505c Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/2] exampletitle\n\nexampledescription","sig":"37d5b2338bf9fd9d598e6494ae88af9a8dbd52330cfe9d025ee55e35e2f3f55e931ba039d9f7fed8e6fc40206e47619a24f730f8eddc2a07ccfb3988a5005170"}"#).unwrap() |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | /// wrapper for a cli testing tool - currently wraps rexpect and dialoguer | 197 | /// wrapper for a cli testing tool - currently wraps rexpect and dialoguer |
diff --git a/tests/init.rs b/tests/init.rs index 5209898..7e2e080 100644 --- a/tests/init.rs +++ b/tests/init.rs | |||
| @@ -57,7 +57,7 @@ mod when_repo_not_previously_claimed { | |||
| 57 | use super::*; | 57 | use super::*; |
| 58 | 58 | ||
| 59 | fn prep_git_repo() -> Result<GitTestRepo> { | 59 | fn prep_git_repo() -> Result<GitTestRepo> { |
| 60 | let test_repo = GitTestRepo::default(); | 60 | let test_repo = GitTestRepo::without_repo_in_git_config(); |
| 61 | test_repo.populate()?; | 61 | test_repo.populate()?; |
| 62 | test_repo.add_remote("origin", "https://localhost:1000")?; | 62 | test_repo.add_remote("origin", "https://localhost:1000")?; |
| 63 | Ok(test_repo) | 63 | Ok(test_repo) |
diff --git a/tests/send.rs b/tests/send.rs index 87bd54f..0f18bd1 100644 --- a/tests/send.rs +++ b/tests/send.rs | |||
| @@ -37,6 +37,8 @@ mod when_commits_behind_ask_to_proceed { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | fn expect_confirm_prompt(p: &mut CliTester) -> Result<CliTesterConfirmPrompt> { | 39 | fn expect_confirm_prompt(p: &mut CliTester) -> Result<CliTesterConfirmPrompt> { |
| 40 | p.expect("fetching updates...\r\n")?; | ||
| 41 | p.expect_eventually("\r\n")?; // may be 'no updates' or some updates | ||
| 40 | p.expect("creating proposal from 2 commits:\r\n")?; | 42 | p.expect("creating proposal from 2 commits:\r\n")?; |
| 41 | p.expect("fe973a8 add t4.md\r\n")?; | 43 | p.expect("fe973a8 add t4.md\r\n")?; |
| 42 | p.expect("232efb3 add t3.md\r\n")?; | 44 | p.expect("232efb3 add t3.md\r\n")?; |
| @@ -130,11 +132,13 @@ fn cli_tester_create_proposal(git_repo: &GitTestRepo, include_cover_letter: bool | |||
| 130 | } | 132 | } |
| 131 | 133 | ||
| 132 | fn expect_msgs_first(p: &mut CliTester, include_cover_letter: bool) -> Result<()> { | 134 | fn expect_msgs_first(p: &mut CliTester, include_cover_letter: bool) -> Result<()> { |
| 135 | p.expect("fetching updates...\r\n")?; | ||
| 136 | p.expect_eventually("\r\n")?; // may be 'no updates' or some updates | ||
| 133 | p.expect("creating proposal from 2 commits:\r\n")?; | 137 | p.expect("creating proposal from 2 commits:\r\n")?; |
| 134 | p.expect("fe973a8 add t4.md\r\n")?; | 138 | p.expect("fe973a8 add t4.md\r\n")?; |
| 135 | p.expect("232efb3 add t3.md\r\n")?; | 139 | p.expect("232efb3 add t3.md\r\n")?; |
| 136 | p.expect("searching for profile...\r\n")?; | 140 | // sometimes there will be a 'searching for profile...' msg |
| 137 | p.expect("logged in as fred\r\n")?; | 141 | p.expect_eventually("logged in as fred\r\n")?; |
| 138 | p.expect(format!( | 142 | p.expect(format!( |
| 139 | "posting 2 patches {} a covering letter...\r\n", | 143 | "posting 2 patches {} a covering letter...\r\n", |
| 140 | if include_cover_letter { | 144 | if include_cover_letter { |
| @@ -921,7 +925,6 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 921 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 925 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 922 | let mut p = cli_tester_create_proposal(&git_repo, true); | 926 | let mut p = cli_tester_create_proposal(&git_repo, true); |
| 923 | expect_msgs_first(&mut p, true)?; | 927 | expect_msgs_first(&mut p, true)?; |
| 924 | // p.expect_end_with("bla")?; | ||
| 925 | relay::expect_send_with_progress( | 928 | relay::expect_send_with_progress( |
| 926 | &mut p, | 929 | &mut p, |
| 927 | vec![ | 930 | vec![ |
| @@ -1159,6 +1162,8 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { | |||
| 1159 | CliTester::new_from_dir(&git_repo.dir, args) | 1162 | CliTester::new_from_dir(&git_repo.dir, args) |
| 1160 | } | 1163 | } |
| 1161 | fn expect_msgs_first(p: &mut CliTester) -> Result<()> { | 1164 | fn expect_msgs_first(p: &mut CliTester) -> Result<()> { |
| 1165 | p.expect("fetching updates...\r\n")?; | ||
| 1166 | p.expect_eventually("\r\n")?; // may be 'no updates' or some updates | ||
| 1162 | let mut selector = p.expect_multi_select( | 1167 | let mut selector = p.expect_multi_select( |
| 1163 | "select commits for proposal", | 1168 | "select commits for proposal", |
| 1164 | vec![ | 1169 | vec![ |
| @@ -1349,7 +1354,6 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1349 | "HEAD~2", | 1354 | "HEAD~2", |
| 1350 | "--in-reply-to", | 1355 | "--in-reply-to", |
| 1351 | &proposal_root_bech32, | 1356 | &proposal_root_bech32, |
| 1352 | // "nevent1qqsged665nx6zz36puey9hzf6ds4n5ctxxzm7c6pfnmvu9l4c9988vgzyr6nuj7d02wdauzfeajx043c5yepjk9v6wm3avycy07kltdsy0tksh0zxyx", | ||
| 1353 | "--title", | 1357 | "--title", |
| 1354 | "exampletitle", | 1358 | "exampletitle", |
| 1355 | "--description", | 1359 | "--description", |
| @@ -1358,16 +1362,16 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1358 | CliTester::new_from_dir(&git_repo.dir, args) | 1362 | CliTester::new_from_dir(&git_repo.dir, args) |
| 1359 | } | 1363 | } |
| 1360 | fn expect_msgs_first(p: &mut CliTester, include_cover_letter: bool) -> Result<()> { | 1364 | fn expect_msgs_first(p: &mut CliTester, include_cover_letter: bool) -> Result<()> { |
| 1365 | p.expect("fetching updates...\r\n")?; | ||
| 1366 | p.expect("updates: 1 new maintainer, 1 announcement update, 1 proposal\r\n")?; | ||
| 1361 | let proposal_root_bech32 = get_pretend_proposal_root_event().id.to_bech32().unwrap(); | 1367 | let proposal_root_bech32 = get_pretend_proposal_root_event().id.to_bech32().unwrap(); |
| 1362 | p.expect(format!( | 1368 | p.expect(format!( |
| 1363 | "creating proposal revision for: {}\r\n", | 1369 | "creating proposal revision for: {}\r\n", |
| 1364 | proposal_root_bech32, | 1370 | proposal_root_bech32, |
| 1365 | ))?; | 1371 | ))?; |
| 1366 | // p.expect("creating proposal revision for: nevent1qqsged665nx6zz36puey9hzf6ds4n5ctxxzm7c6pfnmvu9l4c9988vgzyr6nuj7d02wdauzfeajx043c5yepjk9v6wm3avycy07kltdsy0tksh0zxyx\r\n")?; | ||
| 1367 | p.expect("creating proposal from 2 commits:\r\n")?; | 1372 | p.expect("creating proposal from 2 commits:\r\n")?; |
| 1368 | p.expect("fe973a8 add t4.md\r\n")?; | 1373 | p.expect("fe973a8 add t4.md\r\n")?; |
| 1369 | p.expect("232efb3 add t3.md\r\n")?; | 1374 | p.expect("232efb3 add t3.md\r\n")?; |
| 1370 | p.expect("searching for profile...\r\n")?; | ||
| 1371 | p.expect("logged in as fred\r\n")?; | 1375 | p.expect("logged in as fred\r\n")?; |
| 1372 | p.expect(format!( | 1376 | p.expect(format!( |
| 1373 | "posting 2 patches {} a covering letter...\r\n", | 1377 | "posting 2 patches {} a covering letter...\r\n", |
| @@ -1574,7 +1578,7 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1574 | .unwrap() | 1578 | .unwrap() |
| 1575 | .as_vec()[1], | 1579 | .as_vec()[1], |
| 1576 | // id of state nevent | 1580 | // id of state nevent |
| 1577 | "8cb75aa4cda10a3a0f3242dc49d36159d30b3185bf63414cf6ce17f5c14a73b1", | 1581 | "431e58eb8e1b4e20292d1d5bbe81d5cfb042e1bc165de32eddfdd52245a4cce4", |
| 1578 | ); | 1582 | ); |
| 1579 | } | 1583 | } |
| 1580 | Ok(()) | 1584 | Ok(()) |
| @@ -1620,7 +1624,7 @@ mod in_reply_to_mentions_issue { | |||
| 1620 | } | 1624 | } |
| 1621 | 1625 | ||
| 1622 | fn cli_tester_create_proposal(git_repo: &GitTestRepo) -> CliTester { | 1626 | fn cli_tester_create_proposal(git_repo: &GitTestRepo) -> CliTester { |
| 1623 | let proposal_root_bech32 = get_pretend_issue_event().id.to_bech32().unwrap(); | 1627 | let issue_bech32 = get_pretend_issue_event().id.to_bech32().unwrap(); |
| 1624 | let args = vec![ | 1628 | let args = vec![ |
| 1625 | "--nsec", | 1629 | "--nsec", |
| 1626 | TEST_KEY_1_NSEC, | 1630 | TEST_KEY_1_NSEC, |
| @@ -1630,7 +1634,7 @@ mod in_reply_to_mentions_issue { | |||
| 1630 | "send", | 1634 | "send", |
| 1631 | "HEAD~2", | 1635 | "HEAD~2", |
| 1632 | "--in-reply-to", | 1636 | "--in-reply-to", |
| 1633 | &proposal_root_bech32, | 1637 | &issue_bech32, |
| 1634 | // "note1a9z8vhtzttnny0ggpksd7p5uwf4qu4ys59a52tu9fkz7rrmczkyqc46ngg", | 1638 | // "note1a9z8vhtzttnny0ggpksd7p5uwf4qu4ys59a52tu9fkz7rrmczkyqc46ngg", |
| 1635 | "--title", | 1639 | "--title", |
| 1636 | "exampletitle", | 1640 | "exampletitle", |
| @@ -1738,7 +1742,6 @@ mod in_reply_to_mentions_issue { | |||
| 1738 | } | 1742 | } |
| 1739 | } | 1743 | } |
| 1740 | mod in_reply_to_mentions_npub_and_nprofile_which_get_mentioned_in_proposal_root { | 1744 | mod in_reply_to_mentions_npub_and_nprofile_which_get_mentioned_in_proposal_root { |
| 1741 | use nostr::JsonUtil; | ||
| 1742 | 1745 | ||
| 1743 | use super::*; | 1746 | use super::*; |
| 1744 | 1747 | ||
| @@ -1835,7 +1838,6 @@ mod in_reply_to_mentions_npub_and_nprofile_which_get_mentioned_in_proposal_root | |||
| 1835 | for relay in [&r53, &r55, &r56] { | 1838 | for relay in [&r53, &r55, &r56] { |
| 1836 | let cover_letter_event: &nostr::Event = | 1839 | let cover_letter_event: &nostr::Event = |
| 1837 | relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); | 1840 | relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); |
| 1838 | println!("{:?}", &cover_letter_event.as_json()); | ||
| 1839 | assert!(cover_letter_event.iter_tags().any(|t| { | 1841 | assert!(cover_letter_event.iter_tags().any(|t| { |
| 1840 | t.as_vec()[0].eq("p") | 1842 | t.as_vec()[0].eq("p") |
| 1841 | && t.as_vec()[1].eq(&nostr::Keys::parse( | 1843 | && t.as_vec()[1].eq(&nostr::Keys::parse( |