MCPcopy Create free account
hub / github.com/StepfenShawn/kota / test_function_command

Function test_function_command

tests/test_command.rs:52–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50
51 #[test]
52 fn test_function_command() {
53 let lua = Lua::new();
54 let func: LuaFunction = lua
55 .load(
56 r#"
57 function(args)
58 local file = args.file or "current file"
59 return "run tests for " .. file
60 end
61 "#,
62 )
63 .eval()
64 .unwrap();
65
66 let bytecode = func.dump(false);
67
68 let mut config = KotaConfig::default();
69 config
70 .commands
71 .insert("test".to_string(), CommandDef::Function(bytecode));
72
73 let registry = CommandRegistry::new(&config).unwrap();
74
75 // Without args
76 let result = registry.execute("test", HashMap::new()).unwrap();
77 assert_eq!(result, "run tests for current file");
78
79 // With args
80 let mut args = HashMap::new();
81 args.insert("file".to_string(), "main.rs".to_string());
82 let result = registry.execute("test", args).unwrap();
83 assert_eq!(result, "run tests for main.rs");
84 }
85}

Callers

nothing calls this directly

Calls 2

executeMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected