From 9d491352d161ee629cc47459537344ba0ea4bb35 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 20 Jun 2026 01:11:25 +0800 Subject: Add shared `MockProgramCollect` and conditional `Groupped` bounds Extract duplicate `MockCollect` implementations into a reusable `MockProgramCollect` type. Conditionally require `Serialize` on the `Groupped` trait when the `general_renderer` feature is enabled. --- mingling_core/tests/test-comp/tests/integration.rs | 55 ++-------------------- 1 file changed, 4 insertions(+), 51 deletions(-) (limited to 'mingling_core/tests/test-comp') diff --git a/mingling_core/tests/test-comp/tests/integration.rs b/mingling_core/tests/test-comp/tests/integration.rs index 4e6455e..37aa716 100644 --- a/mingling_core/tests/test-comp/tests/integration.rs +++ b/mingling_core/tests/test-comp/tests/integration.rs @@ -1,55 +1,7 @@ -use mingling::Groupped; +use mingling::MockProgramCollect; use mingling::Program; -use mingling::ProgramCollect; -use mingling::RenderResult; use mingling::comp::{ShellContext, ShellFlag, Suggest, SuggestItem}; -/// Minimal mock collector that satisfies `C: ProgramCollect` -/// by setting `Enum = Self`. -#[derive(Debug, Clone, PartialEq)] -struct MockCollect; - -impl Groupped for MockCollect { - fn member_id() -> MockCollect { - MockCollect - } -} - -impl ProgramCollect for MockCollect { - type Enum = MockCollect; - type ErrorDispatcherNotFound = MockCollect; - type ErrorRendererNotFound = MockCollect; - type ResultEmpty = MockCollect; - - fn build_renderer_not_found(_member_id: MockCollect) -> mingling::AnyOutput { - unimplemented!() - } - fn build_dispatcher_not_found(_args: Vec) -> mingling::AnyOutput { - unimplemented!() - } - fn build_empty_result() -> mingling::AnyOutput { - unimplemented!() - } - fn render(_any: mingling::AnyOutput, _r: &mut RenderResult) { - unimplemented!() - } - fn render_help(_any: mingling::AnyOutput, _r: &mut RenderResult) { - unimplemented!() - } - fn do_chain(_any: mingling::AnyOutput) -> mingling::ChainProcess { - unimplemented!() - } - fn do_comp(_any: &mingling::AnyOutput, _ctx: &ShellContext) -> Suggest { - unimplemented!() - } - fn has_renderer(_any: &mingling::AnyOutput) -> bool { - unimplemented!() - } - fn has_chain(_any: &mingling::AnyOutput) -> bool { - unimplemented!() - } -} - #[test] fn test_shell_context_parsing_full() { let args = vec![ @@ -112,12 +64,13 @@ fn test_suggest_item_with_description() { #[test] fn test_program_is_completing() { - let program: Program = Program::new_with_args(["myapp", "__comp", "hello", ""]); + let program: Program = + Program::new_with_args(["myapp", "__comp", "hello", ""]); assert!(program.is_completing()); } #[test] fn test_program_is_not_completing() { - let program: Program = Program::new_with_args(["myapp", "hello"]); + let program: Program = Program::new_with_args(["myapp", "hello"]); assert!(!program.is_completing()); } -- cgit