From 0c5a3c001ccafd458a9b99b7513a9c8c172a54b2 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 25 Nov 2024 16:09:36 +0000 Subject: feat(list): report on action selection there was a bug in `Interactor` so that reports were turned off by default for choices. This was embodied into the CLI tests but this turns them on in these scenarios. --- src/lib/cli_interactor.rs | 14 +++++++++++--- test_utils/src/lib.rs | 2 +- tests/ngit_list.rs | 32 ++++++++++++++++---------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/lib/cli_interactor.rs b/src/lib/cli_interactor.rs index 2ceb088..50a0f0c 100644 --- a/src/lib/cli_interactor.rs +++ b/src/lib/cli_interactor.rs @@ -178,7 +178,6 @@ impl Default for PromptChoiceParms { impl PromptChoiceParms { pub fn with_prompt>(mut self, prompt: S) -> Self { self.prompt = prompt.into(); - self.report = true; self } @@ -198,7 +197,6 @@ impl PromptChoiceParms { } } -#[derive(Default)] pub struct PromptMultiChoiceParms { pub prompt: String, pub choices: Vec, @@ -206,10 +204,20 @@ pub struct PromptMultiChoiceParms { pub report: bool, } +impl Default for PromptMultiChoiceParms { + fn default() -> Self { + Self { + prompt: String::new(), + choices: vec![], + defaults: None, + report: true, + } + } +} + impl PromptMultiChoiceParms { pub fn with_prompt>(mut self, prompt: S) -> Self { self.prompt = prompt.into(); - self.report = true; self } diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index cfbc381..ec05cfd 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -1298,7 +1298,7 @@ pub fn use_ngit_list_to_download_and_checkout_proposal_branch( format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect_end_eventually()?; Ok(()) } diff --git a/tests/ngit_list.rs b/tests/ngit_list.rs index 6382451..a6b1374 100644 --- a/tests/ngit_list.rs +++ b/tests/ngit_list.rs @@ -195,7 +195,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, None)?; + c.succeeds_with(0, true, None)?; p.expect(format!( "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_1, @@ -317,7 +317,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect(format!( "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_3, @@ -443,7 +443,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect_end_eventually_and_print()?; for p in [51, 52, 53, 55, 56] { @@ -524,7 +524,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect(format!( "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_4, @@ -647,7 +647,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect_end_eventually()?; test_repo.checkout("main")?; @@ -673,7 +673,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect_end_eventually_and_print()?; for p in [51, 52, 53, 55, 56] { @@ -745,7 +745,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect_end_eventually()?; test_repo.checkout("main")?; @@ -771,7 +771,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + c.succeeds_with(0, true, Some(0))?; p.expect(format!( "checked out proposal as 'pr/{}(", FEATURE_BRANCH_NAME_1, @@ -862,7 +862,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + 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()?; @@ -938,7 +938,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + 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()?; @@ -1056,7 +1056,7 @@ mod when_main_branch_is_uptodate { "back".to_string(), ], )?; - c.succeeds_with(1, false, Some(0))?; + c.succeeds_with(1, true, Some(0))?; p.expect_end_eventually_and_print()?; @@ -1140,7 +1140,7 @@ mod when_main_branch_is_uptodate { "back".to_string(), ], )?; - c.succeeds_with(1, false, Some(1))?; + 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")?; for p in [51, 52, 53, 55, 56] { @@ -1237,7 +1237,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + 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,7 +1319,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + 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,7 +1421,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + 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,7 +1494,7 @@ mod when_main_branch_is_uptodate { format!("back"), ], )?; - c.succeeds_with(0, false, Some(0))?; + 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()?; -- cgit v1.2.3