generated from nhcarrigan/template
feat(tools): set up proper CI (#2)
### Explanation _No response_ ### Issue _No response_ ### Attestations - [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/) - [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/). - [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/). ### Dependencies - [ ] I have pinned the dependencies to a specific patch version. ### Style - [ ] I have run the linter and resolved any errors. - [ ] My pull request uses an appropriate title, matching the conventional commit standards. - [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request. ### Tests - [ ] My contribution adds new code, and I have added tests to cover it. - [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes. - [ ] All new and existing tests pass locally with my changes. - [ ] Code coverage remains at or above the configured threshold. ### Documentation _No response_ ### Versioning _No response_ Reviewed-on: #2 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit was merged in pull request #2.
This commit is contained in:
@@ -472,3 +472,127 @@ pub type SharedBridge = Arc<Mutex<WslBridge>>;
|
||||
pub fn create_shared_bridge() -> SharedBridge {
|
||||
Arc::new(Mutex::new(WslBridge::new()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_get_tool_state_search_tools() {
|
||||
assert!(matches!(get_tool_state("Read"), CharacterState::Searching));
|
||||
assert!(matches!(get_tool_state("Glob"), CharacterState::Searching));
|
||||
assert!(matches!(get_tool_state("Grep"), CharacterState::Searching));
|
||||
assert!(matches!(get_tool_state("WebSearch"), CharacterState::Searching));
|
||||
assert!(matches!(get_tool_state("WebFetch"), CharacterState::Searching));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_tool_state_coding_tools() {
|
||||
assert!(matches!(get_tool_state("Edit"), CharacterState::Coding));
|
||||
assert!(matches!(get_tool_state("Write"), CharacterState::Coding));
|
||||
assert!(matches!(get_tool_state("NotebookEdit"), CharacterState::Coding));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_tool_state_mcp_tools() {
|
||||
assert!(matches!(get_tool_state("mcp__github__create_issue"), CharacterState::Mcp));
|
||||
assert!(matches!(get_tool_state("mcp__notion__search"), CharacterState::Mcp));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_tool_state_task() {
|
||||
assert!(matches!(get_tool_state("Task"), CharacterState::Thinking));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_tool_state_unknown() {
|
||||
assert!(matches!(get_tool_state("SomeUnknownTool"), CharacterState::Typing));
|
||||
assert!(matches!(get_tool_state("Bash"), CharacterState::Typing));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_read() {
|
||||
let input = serde_json::json!({"file_path": "/home/test/file.txt"});
|
||||
let desc = format_tool_description("Read", &input);
|
||||
assert_eq!(desc, "Reading file: /home/test/file.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_read_no_path() {
|
||||
let input = serde_json::json!({});
|
||||
let desc = format_tool_description("Read", &input);
|
||||
assert_eq!(desc, "Reading file...");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_glob() {
|
||||
let input = serde_json::json!({"pattern": "**/*.rs"});
|
||||
let desc = format_tool_description("Glob", &input);
|
||||
assert_eq!(desc, "Searching for files: **/*.rs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_grep() {
|
||||
let input = serde_json::json!({"pattern": "TODO"});
|
||||
let desc = format_tool_description("Grep", &input);
|
||||
assert_eq!(desc, "Searching for: TODO");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_edit() {
|
||||
let input = serde_json::json!({"file_path": "/home/test/main.rs"});
|
||||
let desc = format_tool_description("Edit", &input);
|
||||
assert_eq!(desc, "Editing: /home/test/main.rs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_write() {
|
||||
let input = serde_json::json!({"file_path": "/home/test/new.txt"});
|
||||
let desc = format_tool_description("Write", &input);
|
||||
assert_eq!(desc, "Editing: /home/test/new.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_bash_short() {
|
||||
let input = serde_json::json!({"command": "ls -la"});
|
||||
let desc = format_tool_description("Bash", &input);
|
||||
assert_eq!(desc, "Running: ls -la");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_bash_long() {
|
||||
let long_cmd = "a".repeat(100);
|
||||
let input = serde_json::json!({"command": long_cmd});
|
||||
let desc = format_tool_description("Bash", &input);
|
||||
assert!(desc.starts_with("Running: "));
|
||||
assert!(desc.ends_with("..."));
|
||||
assert!(desc.len() < 70);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_description_unknown() {
|
||||
let input = serde_json::json!({"some": "data"});
|
||||
let desc = format_tool_description("CustomTool", &input);
|
||||
assert_eq!(desc, "Using tool: CustomTool");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_wsl_bridge_new() {
|
||||
let bridge = WslBridge::new();
|
||||
assert!(!bridge.is_running());
|
||||
assert_eq!(bridge.get_working_directory(), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_wsl_bridge_default() {
|
||||
let bridge = WslBridge::default();
|
||||
assert!(!bridge.is_running());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_shared_bridge() {
|
||||
let shared = create_shared_bridge();
|
||||
let bridge = shared.lock();
|
||||
assert!(!bridge.is_running());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user