Test coverage and headless nvim bug fixes
This commit is contained in:
1 parent
bffc8896f1
commit
4bae4e9c08
9 files changed
+316
-58
No files matched your search
@@ -147,7 +147,16 @@ impl McpTool for CreateRelationsHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||
let req: CreateRelationsTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: CreateRelationsTool = match serde_json::from_value(args.clone()) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
let err_msg = e.to_string();
|
||||
if err_msg.contains("missing field `from`") || err_msg.contains("missing field `to`") || err_msg.contains("missing field `relation_type`") {
|
||||
return Err(format!("Schema error: {}. Note that the relation schema strictly uses 'from', 'to', and 'relation_type' (not 'source', 'target', or 'relationType'). Please correct your tool call arguments.", err_msg));
|
||||
}
|
||||
return Err(err_msg);
|
||||
}
|
||||
};
|
||||
let mut missing_nodes = std::collections::HashSet::new();
|
||||
state.modify_graph(|g| {
|
||||
for relation in req.relations {
|
||||
@@ -682,6 +691,16 @@ mod tests {
|
||||
});
|
||||
let res = handler.execute(args, state.clone()).await.unwrap();
|
||||
assert_eq!(res, "Relations created");
|
||||
|
||||
// Test semantic LLM schema feedback (User request)
|
||||
let bad_args = json!({
|
||||
"relations": [
|
||||
{"source": "A", "target": "B", "relationType": "knows"}
|
||||
]
|
||||
});
|
||||
let err_res = handler.execute(bad_args, state.clone()).await.unwrap_err();
|
||||
assert!(err_res.contains("Schema error:"));
|
||||
assert!(err_res.contains("strictly uses 'from', 'to', and 'relation_type'"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -344,6 +344,7 @@ impl McpTool for OmniSearchHandler {
|
||||
idx.search(&req.query, req.namespace.as_deref())
|
||||
.unwrap_or_default()
|
||||
};
|
||||
println!("OMNI SEARCH MATCHES: {:?}", matches);
|
||||
|
||||
let kg_json = state.read_graph(|full| {
|
||||
let mut kg_entities = std::collections::HashMap::new();
|
||||
@@ -660,4 +661,40 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_omni_search() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let state = Arc::new(MemoryState::new(dir.path().to_str().unwrap()));
|
||||
|
||||
let task = crate::models::Task {
|
||||
id: "omni-1".to_string(),
|
||||
title: "Omni Task".to_string(),
|
||||
description: "Testing omni search functionality".to_string(),
|
||||
status: "open".to_string(),
|
||||
created_at: 0,
|
||||
updated_at: 0,
|
||||
git_branch: None,
|
||||
parent_id: None,
|
||||
dependencies: vec![],
|
||||
acceptance_criteria: vec![],
|
||||
};
|
||||
|
||||
{
|
||||
state.tasks.modify(|t| {
|
||||
t.push(task.clone());
|
||||
});
|
||||
}
|
||||
|
||||
state.rebuild_index().await;
|
||||
state.get_search_index().reader.reload().unwrap();
|
||||
|
||||
let omni = OmniSearchHandler;
|
||||
let omni_res = omni
|
||||
.execute(json!({"query": "Omni"}), state.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
println!("OMNI RES: {}", omni_res);
|
||||
assert!(omni_res.contains("omni-1"), "omni search should return results containing the task id");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user