refactor: Implement unified search abstraction, MemoryState refactoring, error handling, and unit test expansion
This commit is contained in:
1 parent
a34554b7ff
commit
462f65f66d
21 files changed
+425
-535
No files matched your search
@@ -499,13 +499,13 @@ mod tests {
|
||||
"acceptance_criteria": ["Stop the noise", "Reach lightspeed"],
|
||||
});
|
||||
|
||||
let res = add_handler.execute(args, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
let res = add_handler.execute(args, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert!(res.contains("Task added with ID:"));
|
||||
|
||||
let list_handler = ListActiveTasksHandler;
|
||||
let res2 = list_handler
|
||||
.execute(json!({}), state.clone())
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert!(res2.contains("Fix the hyperdrive"));
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ mod tests {
|
||||
json!({"title": "Test", "description": "test"}),
|
||||
state.clone(),
|
||||
)
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
|
||||
let id_start = res.find("ID: ").unwrap() + 4;
|
||||
let task_id = res[id_start..].trim();
|
||||
@@ -530,13 +530,13 @@ mod tests {
|
||||
"id": task_id,
|
||||
"status": "done"
|
||||
});
|
||||
let res3 = update_handler.execute(args, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
let res3 = update_handler.execute(args, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert_eq!(res3, "Task status updated.");
|
||||
|
||||
let list_handler = ListActiveTasksHandler;
|
||||
let res4 = list_handler
|
||||
.execute(json!({}), state.clone())
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert!(!res4.contains(task_id));
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ mod tests {
|
||||
"end_date": 1700000000,
|
||||
"namespace": "global"
|
||||
});
|
||||
let res1 = add_milestone.execute(args_ms, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
let res1 = add_milestone.execute(args_ms, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert!(res1.contains("Milestone added"));
|
||||
|
||||
// Fetch milestone ID from state directly to update
|
||||
@@ -567,14 +567,14 @@ mod tests {
|
||||
"id": ms_id,
|
||||
"status": "completed"
|
||||
});
|
||||
let res2 = update_ms.execute(args_ums, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
let res2 = update_ms.execute(args_ums, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert_eq!(res2, "Milestone updated");
|
||||
|
||||
// List Milestones
|
||||
let list_ms = ListMilestonesHandler;
|
||||
let res3 = list_ms
|
||||
.execute(json!({"namespace": "global"}), state.clone())
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert!(res3.contains("completed"));
|
||||
assert!(res3.contains("Release 1.0"));
|
||||
|
||||
@@ -585,7 +585,7 @@ mod tests {
|
||||
json!({"title": "Test", "description": "desc"}),
|
||||
state.clone(),
|
||||
)
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
let task_id = res_task[res_task.find("ID: ").unwrap() + 4..].trim();
|
||||
|
||||
let set_ac = SetAcceptanceCriteriaHandler;
|
||||
@@ -594,7 +594,7 @@ mod tests {
|
||||
"task_title": "Test",
|
||||
"criteria": ["Do X", "Do Y"]
|
||||
});
|
||||
let res4 = set_ac.execute(args_ac, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
let res4 = set_ac.execute(args_ac, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert_eq!(res4, "Acceptance criteria set successfully.");
|
||||
|
||||
let verify_ac = VerifyAcceptanceCriteriaHandler;
|
||||
@@ -603,7 +603,7 @@ mod tests {
|
||||
"criteria": "Do X",
|
||||
"proof": "I did X"
|
||||
});
|
||||
let res5 = verify_ac.execute(args_vac, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
let res5 = verify_ac.execute(args_vac, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert!(res5.contains("Acceptance criteria verified"));
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ mod tests {
|
||||
json!({"title": "Parent", "description": "p"}),
|
||||
state.clone(),
|
||||
)
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
let parent_id = parent[parent.find("ID: ").unwrap() + 4..]
|
||||
.trim()
|
||||
.to_string();
|
||||
@@ -628,13 +628,13 @@ mod tests {
|
||||
json!({"title": "Child", "description": "c", "parent_id": parent_id}),
|
||||
state.clone(),
|
||||
)
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
let _child_id = child[child.find("ID: ").unwrap() + 4..].trim().to_string();
|
||||
|
||||
let del_task = DeleteTaskHandler;
|
||||
let res_del = del_task
|
||||
.execute(json!({"id": parent_id}), state.clone())
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
|
||||
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
|
||||
assert!(res_del.contains("Deleted task and its children (2 total)."));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user