MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_custom_command

Function test_custom_command

core/src/commands.rs:531–553  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

529
530 #[test]
531 fn test_custom_command() {
532 struct PingCommand;
533 impl SlashCommand for PingCommand {
534 fn name(&self) -> &str {
535 "ping"
536 }
537 fn description(&self) -> &str {
538 "Pong!"
539 }
540 fn execute(&self, _args: &str, _ctx: &CommandContext) -> CommandOutput {
541 CommandOutput::text("pong")
542 }
543 }
544
545 let mut reg = CommandRegistry::new();
546 let before = reg.len();
547 reg.register(Arc::new(PingCommand));
548 assert_eq!(reg.len(), before + 1);
549
550 let ctx = test_ctx();
551 let out = reg.dispatch("/ping", &ctx).unwrap();
552 assert_eq!(out.text, "pong");
553 }
554
555 #[test]
556 fn test_list_commands() {

Callers

nothing calls this directly

Calls 4

test_ctxFunction · 0.85
lenMethod · 0.45
registerMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected