bottest/tests/unit/basic/basic_keywords_add_suggestion.rs

67 lines
No EOL
1.9 KiB
Rust

//! Unit tests migrated from src/basic/keywords/add_suggestion.rs
//! These tests were originally in botserver and have been migrated to bottest.
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
// Original: use super::*; - tests used internal functions from botserver
#[test]
fn test_suggestion_json_context() {
let suggestion = json!({
"type": "context",
"context": "products",
"text": "View Products",
"action": {
"type": "select_context",
"context": "products"
}
});
assert_eq!(suggestion["type"], "context");
assert_eq!(suggestion["action"]["type"], "select_context");
}
#[test]
fn test_suggestion_json_tool_no_params() {
let suggestion = json!({
"type": "tool",
"tool": "search_kb",
"text": "Search Knowledge Base",
"action": {
"type": "invoke_tool",
"tool": "search_kb",
"params": Option::<Vec<String>>::None,
"prompt_for_params": true
}
});
assert_eq!(suggestion["type"], "tool");
assert_eq!(suggestion["action"]["prompt_for_params"], true);
}
#[test]
fn test_suggestion_json_tool_with_params() {
let params = vec!["query".to_string(), "products".to_string()];
let suggestion = json!({
"type": "tool",
"tool": "search_kb",
"text": "Search Products",
"action": {
"type": "invoke_tool",
"tool": "search_kb",
"params": params,
"prompt_for_params": false
}
});
assert_eq!(suggestion["type"], "tool");
assert_eq!(suggestion["action"]["prompt_for_params"], false);
assert!(suggestion["action"]["params"].is_array());
}