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` --- test_utils/src/lib.rs | 203 ++++++++++++++++++++---------------------------- test_utils/src/relay.rs | 2 +- 2 files changed, 84 insertions(+), 121 deletions(-) (limited to 'test_utils/src') diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 5079c26..5c8d7a5 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -6,15 +6,15 @@ use std::{ time::Duration, }; -use anyhow::{bail, ensure, Context, Result}; +use anyhow::{Context, Result, bail, ensure}; use dialoguer::theme::{ColorfulTheme, Theme}; use futures::executor::block_on; use git::GitTestRepo; use git2::{Signature, Time}; -use nostr::{self, nips::nip65::RelayMetadata, Kind, Tag}; +use nostr::{self, Kind, Tag, nips::nip65::RelayMetadata}; use nostr_database::NostrEventsDatabase; use nostr_lmdb::NostrLMDB; -use nostr_sdk::{serde_json, Client, NostrSigner, TagStandard}; +use nostr_sdk::{Client, NostrSigner, TagStandard, serde_json}; use once_cell::sync::Lazy; use rexpect::session::{Options, PtySession}; use strip_ansi_escapes::strip_str; @@ -530,14 +530,10 @@ 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"); @@ -1007,13 +1003,10 @@ 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( @@ -1031,13 +1024,10 @@ 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( @@ -1052,13 +1042,10 @@ 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( @@ -1102,13 +1089,10 @@ 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") } @@ -1137,14 +1121,11 @@ 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) } @@ -1296,54 +1277,45 @@ 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(()) @@ -1375,14 +1347,11 @@ 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 @@ -1394,15 +1363,12 @@ 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(()) @@ -1505,18 +1471,15 @@ 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 d767a5a..634b2d6 100644 --- a/test_utils/src/relay.rs +++ b/test_utils/src/relay.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use nostr::{ClientMessage, JsonUtil, RelayMessage}; use crate::CliTester; -- cgit v1.2.3