MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_grep_find_pattern

Function test_grep_find_pattern

core/src/tools/builtin/grep.rs:140–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138
139 #[tokio::test]
140 async fn test_grep_find_pattern() {
141 let temp = tempfile::tempdir().unwrap();
142 std::fs::write(
143 temp.path().join("a.txt"),
144 "hello world\nfoo bar\nhello again",
145 )
146 .unwrap();
147 std::fs::write(temp.path().join("b.txt"), "no match here").unwrap();
148
149 let tool = GrepTool;
150 let ctx = ToolContext::new(temp.path().to_path_buf());
151
152 let result = tool
153 .execute(&serde_json::json!({"pattern": "hello"}), &ctx)
154 .await
155 .unwrap();
156
157 assert!(result.success);
158 assert!(result.content.contains("hello world"));
159 assert!(result.content.contains("hello again"));
160 assert!(result.content.contains("2 match(es)"));
161 }
162
163 #[tokio::test]
164 async fn test_grep_no_match() {

Callers

nothing calls this directly

Calls 3

writeFunction · 0.85
pathMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected