Skip to content

Commit 200aa13

Browse files
committed
add mcp ut
1 parent 13707d4 commit 200aa13

File tree

1 file changed

+63
-4
lines changed

1 file changed

+63
-4
lines changed

crates/q_cli/src/cli/mod.rs

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,13 @@ async fn launch_dashboard(help_fallback: bool) -> Result<ExitCode> {
487487

488488
#[cfg(test)]
489489
mod test {
490-
use q_chat::cli::McpAdd;
490+
use q_chat::cli::{
491+
McpAdd,
492+
McpImport,
493+
McpList,
494+
McpRemove,
495+
Scope,
496+
};
491497

492498
use super::*;
493499

@@ -790,7 +796,7 @@ mod test {
790796
}
791797

792798
#[test]
793-
fn test_mcp_subcommand() {
799+
fn test_mcp_subcomman_add() {
794800
assert_parse!(
795801
[
796802
"mcp",
@@ -809,15 +815,68 @@ mod test {
809815
command: "test_command".to_string(),
810816
scope: None,
811817
profile: Some("my_profile".to_string()),
812-
env: Some(
818+
env: vec![
813819
[
814820
("key1".to_string(), "value1".to_string()),
815821
("key2".to_string(), "value2".to_string())
816822
]
817823
.into_iter()
818824
.collect()
819-
),
825+
],
820826
timeout: None,
827+
force: false,
828+
}))
829+
);
830+
}
831+
832+
#[test]
833+
fn test_mcp_subcomman_remove_workspace() {
834+
assert_parse!(
835+
["mcp", "remove", "--name", "old"],
836+
CliRootCommands::Mcp(Mcp::Remove(McpRemove {
837+
name: "old".into(),
838+
scope: None,
839+
profile: None,
840+
}))
841+
);
842+
}
843+
#[test]
844+
fn test_mcp_subcomman_import_profile_force() {
845+
assert_parse!(
846+
[
847+
"mcp",
848+
"import",
849+
"--file",
850+
"servers.json",
851+
"profile",
852+
"--profile",
853+
"qa",
854+
"--force"
855+
],
856+
CliRootCommands::Mcp(Mcp::Import(McpImport {
857+
file: "servers.json".into(),
858+
scope: Some(Scope::Profile),
859+
profile: Some("qa".into()),
860+
force: true,
861+
}))
862+
);
863+
}
864+
865+
#[test]
866+
fn test_mcp_subcommand_status_simple() {
867+
assert_parse!(
868+
["mcp", "status", "--name", "aws"],
869+
CliRootCommands::Mcp(Mcp::Status { name: "aws".into() })
870+
);
871+
}
872+
873+
#[test]
874+
fn test_mcp_subcommand_list() {
875+
assert_parse!(
876+
["mcp", "list", "global"],
877+
CliRootCommands::Mcp(Mcp::List( McpList{
878+
scope: Some(Scope::Global),
879+
profile: None
821880
}))
822881
);
823882
}

0 commit comments

Comments
 (0)