|
16 | 16 | (is (match? |
17 | 17 | {:error true |
18 | 18 | :contents [{:type :text |
19 | | - :content (str (h/file-path "/foo/qux") " is not a valid path")}]} |
| 19 | + :text (str (h/file-path "/foo/qux") " is not a valid path")}]} |
20 | 20 | (with-redefs [fs/canonicalize (constantly (h/file-path "/foo/qux")) |
21 | 21 | fs/exists? (constantly false)] |
22 | 22 | ((get-in f.tools.filesystem/definitions ["eca_list_directory" :handler]) |
|
26 | 26 | (is (match? |
27 | 27 | {:error true |
28 | 28 | :contents [{:type :text |
29 | | - :content (format "Access denied - path %s outside allowed directories: %s" |
| 29 | + :text (format "Access denied - path %s outside allowed directories: %s" |
30 | 30 | (h/file-path "/foo/qux") |
31 | 31 | (h/file-path "/foo/bar/baz"))}]} |
32 | 32 | (with-redefs [fs/canonicalize (constantly (h/file-path "/foo/qux")) |
|
38 | 38 | (is (match? |
39 | 39 | {:error false |
40 | 40 | :contents [{:type :text |
41 | | - :content (format (str "[FILE] %s\n" |
| 41 | + :text (format (str "[FILE] %s\n" |
42 | 42 | "[DIR] %s\n") |
43 | 43 | (h/file-path "/foo/bar/baz/some.clj") |
44 | 44 | (h/file-path "/foo/bar/baz/qux"))}]} |
|
57 | 57 | (is (match? |
58 | 58 | {:error true |
59 | 59 | :contents [{:type :text |
60 | | - :content (format "File %s is not readable" (h/file-path "/foo/qux"))}]} |
| 60 | + :text (format "File %s is not readable" (h/file-path "/foo/qux"))}]} |
61 | 61 | (with-redefs [fs/exists? (constantly true) |
62 | 62 | fs/readable? (constantly false) |
63 | 63 | f.tools.filesystem/allowed-path? (constantly true)] |
|
68 | 68 | (is (match? |
69 | 69 | {:error false |
70 | 70 | :contents [{:type :text |
71 | | - :content "fooo"}]} |
| 71 | + :text "fooo"}]} |
72 | 72 | (with-redefs [slurp (constantly "fooo") |
73 | 73 | fs/exists? (constantly true) |
74 | 74 | fs/readable? (constantly true) |
|
80 | 80 | (is (match? |
81 | 81 | {:error false |
82 | 82 | :contents [{:type :text |
83 | | - :content "line3\nline4\nline5"}]} |
| 83 | + :text "line3\nline4\nline5"}]} |
84 | 84 | (with-redefs [slurp (constantly "line1\nline2\nline3\nline4\nline5") |
85 | 85 | fs/exists? (constantly true) |
86 | 86 | fs/readable? (constantly true) |
|
92 | 92 | (is (match? |
93 | 93 | {:error false |
94 | 94 | :contents [{:type :text |
95 | | - :content "line1\nline2"}]} |
| 95 | + :text "line1\nline2"}]} |
96 | 96 | (with-redefs [slurp (constantly "line1\nline2\nline3\nline4\nline5") |
97 | 97 | fs/exists? (constantly true) |
98 | 98 | fs/readable? (constantly true) |
|
104 | 104 | (is (match? |
105 | 105 | {:error false |
106 | 106 | :contents [{:type :text |
107 | | - :content "line3\nline4"}]} |
| 107 | + :text "line3\nline4"}]} |
108 | 108 | (with-redefs [slurp (constantly "line1\nline2\nline3\nline4\nline5") |
109 | 109 | fs/exists? (constantly true) |
110 | 110 | fs/readable? (constantly true) |
|
118 | 118 | (is (match? |
119 | 119 | {:error true |
120 | 120 | :contents [{:type :text |
121 | | - :content (format "Access denied - path %s outside allowed directories: %s" |
| 121 | + :text (format "Access denied - path %s outside allowed directories: %s" |
122 | 122 | (h/file-path "/foo/qux/new_file.clj") |
123 | 123 | (h/file-path "/foo/bar"))}]} |
124 | 124 | (with-redefs [f.tools.filesystem/allowed-path? (constantly false)] |
|
131 | 131 | (is (match? |
132 | 132 | {:error true |
133 | 133 | :contents [{:type :text |
134 | | - :content "Invalid glob pattern ' '"}]} |
| 134 | + :text "Invalid glob pattern ' '"}]} |
135 | 135 | (with-redefs [fs/exists? (constantly true)] |
136 | 136 | ((get-in f.tools.filesystem/definitions ["eca_search_files" :handler]) |
137 | 137 | {"path" (h/file-path "/project/foo") |
|
141 | 141 | (is (match? |
142 | 142 | {:error true |
143 | 143 | :contents [{:type :text |
144 | | - :content "No matches found"}]} |
| 144 | + :text "No matches found"}]} |
145 | 145 | (with-redefs [fs/exists? (constantly true) |
146 | 146 | fs/glob (constantly [])] |
147 | 147 | ((get-in f.tools.filesystem/definitions ["eca_search_files" :handler]) |
|
152 | 152 | (is (match? |
153 | 153 | {:error false |
154 | 154 | :contents [{:type :text |
155 | | - :content (str (h/file-path "/project/foo/bar/baz.txt") "\n" |
| 155 | + :text (str (h/file-path "/project/foo/bar/baz.txt") "\n" |
156 | 156 | (h/file-path "/project/foo/qux.txt") "\n" |
157 | 157 | (h/file-path "/project/foo/qux.clj"))}]} |
158 | 158 | (with-redefs [fs/exists? (constantly true) |
|
167 | 167 | (is (match? |
168 | 168 | {:error false |
169 | 169 | :contents [{:type :text |
170 | | - :content (str (h/file-path "/project/foo/bar/baz.txt") "\n" |
| 170 | + :text (str (h/file-path "/project/foo/bar/baz.txt") "\n" |
171 | 171 | (h/file-path "/project/foo/qux.txt"))}]} |
172 | 172 | (with-redefs [fs/exists? (constantly true) |
173 | 173 | fs/glob (constantly [(fs/path (h/file-path "/project/foo/bar/baz.txt")) |
|
182 | 182 | (is (match? |
183 | 183 | {:error true |
184 | 184 | :contents [{:type :text |
185 | | - :content "Invalid content regex pattern ' '"}]} |
| 185 | + :text "Invalid content regex pattern ' '"}]} |
186 | 186 | (with-redefs [fs/exists? (constantly true) |
187 | 187 | fs/readable? (constantly true)] |
188 | 188 | ((get-in f.tools.filesystem/definitions ["eca_grep" :handler]) |
|
193 | 193 | (is (match? |
194 | 194 | {:error true |
195 | 195 | :contents [{:type :text |
196 | | - :content "Invalid file pattern ' '"}]} |
| 196 | + :text "Invalid file pattern ' '"}]} |
197 | 197 | (with-redefs [fs/exists? (constantly true) |
198 | 198 | fs/readable? (constantly true)] |
199 | 199 | ((get-in f.tools.filesystem/definitions ["eca_grep" :handler]) |
|
205 | 205 | (is (match? |
206 | 206 | {:error true |
207 | 207 | :contents [{:type :text |
208 | | - :content "No files found for given pattern"}]} |
| 208 | + :text "No files found for given pattern"}]} |
209 | 209 | (with-redefs [fs/exists? (constantly true) |
210 | 210 | fs/readable? (constantly true) |
211 | 211 | tools.util/command-available? (fn [command & _args] (= "rg" command)) |
|
218 | 218 | (is (match? |
219 | 219 | {:error false |
220 | 220 | :contents [{:type :text |
221 | | - :content "/project/foo/bla.txt\n/project/foo/qux.txt"}]} |
| 221 | + :text "/project/foo/bla.txt\n/project/foo/qux.txt"}]} |
222 | 222 | (with-redefs [fs/exists? (constantly true) |
223 | 223 | fs/readable? (constantly true) |
224 | 224 | tools.util/command-available? (fn [command & _args] (= "rg" command)) |
|
231 | 231 | (is (match? |
232 | 232 | {:error false |
233 | 233 | :contents [{:type :text |
234 | | - :content "/project/foo/bla.txt\n/project/foo/qux.txt"}]} |
| 234 | + :text "/project/foo/bla.txt\n/project/foo/qux.txt"}]} |
235 | 235 | (with-redefs [fs/exists? (constantly true) |
236 | 236 | fs/readable? (constantly true) |
237 | 237 | tools.util/command-available? (fn [command & _args] (= "grep" command)) |
|
244 | 244 | (is (match? |
245 | 245 | {:error false |
246 | 246 | :contents [{:type :text |
247 | | - :content (h/file-path "/project/foo/bla.txt")}]} |
| 247 | + :text (h/file-path "/project/foo/bla.txt")}]} |
248 | 248 | (with-redefs [fs/exists? (constantly true) |
249 | 249 | fs/readable? (constantly true) |
250 | 250 | tools.util/command-available? (constantly false) |
|
264 | 264 | (is (match? |
265 | 265 | {:error true |
266 | 266 | :contents [{:type :text |
267 | | - :content (format "File %s is not readable" (h/file-path "/foo/qux"))}]} |
| 267 | + :text (format "File %s is not readable" (h/file-path "/foo/qux"))}]} |
268 | 268 | (with-redefs [fs/exists? (constantly true) |
269 | 269 | fs/readable? (constantly false) |
270 | 270 | f.tools.filesystem/allowed-path? (constantly true)] |
|
277 | 277 | (is (match? |
278 | 278 | {:error true |
279 | 279 | :contents [{:type :text |
280 | | - :content (format "Original content not found in %s" (h/file-path "/project/foo/my-file.txt"))}]} |
| 280 | + :text (format "Original content not found in %s" (h/file-path "/project/foo/my-file.txt"))}]} |
281 | 281 | (with-redefs [fs/exists? (constantly true) |
282 | 282 | fs/readable? (constantly true) |
283 | 283 | f.tools.filesystem/allowed-path? (constantly true) |
|
292 | 292 | (is (match? |
293 | 293 | {:error false |
294 | 294 | :contents [{:type :text |
295 | | - :content (format "Successfully replaced content in %s." (h/file-path "/project/foo/my-file.txt"))}]} |
| 295 | + :text (format "Successfully replaced content in %s." (h/file-path "/project/foo/my-file.txt"))}]} |
296 | 296 | (with-redefs [fs/exists? (constantly true) |
297 | 297 | fs/readable? (constantly true) |
298 | 298 | f.tools.filesystem/allowed-path? (constantly true) |
|
311 | 311 | (is (match? |
312 | 312 | {:error false |
313 | 313 | :contents [{:type :text |
314 | | - :content (format "Successfully replaced content in %s." (h/file-path "/project/foo/my-file.txt"))}]} |
| 314 | + :text (format "Successfully replaced content in %s." (h/file-path "/project/foo/my-file.txt"))}]} |
315 | 315 | (with-redefs [fs/exists? (constantly true) |
316 | 316 | fs/readable? (constantly true) |
317 | 317 | f.tools.filesystem/allowed-path? (constantly true) |
|
332 | 332 | (is (match? |
333 | 333 | {:error true |
334 | 334 | :contents [{:type :text |
335 | | - :content (format "%s is not a valid path" (h/file-path "/foo/qux"))}]} |
| 335 | + :text (format "%s is not a valid path" (h/file-path "/foo/qux"))}]} |
336 | 336 | (with-redefs [fs/exists? (constantly false) |
337 | 337 | f.tools.filesystem/allowed-path? (constantly true)] |
338 | 338 | ((get-in f.tools.filesystem/definitions ["eca_move_file" :handler]) |
|
342 | 342 | (is (match? |
343 | 343 | {:error true |
344 | 344 | :contents [{:type :text |
345 | | - :content (format "Path %s already exists" (h/file-path "/foo/bar/other_file.clj"))}]} |
| 345 | + :text (format "Path %s already exists" (h/file-path "/foo/bar/other_file.clj"))}]} |
346 | 346 | (with-redefs [fs/exists? (constantly true) |
347 | 347 | f.tools.filesystem/allowed-path? (constantly true)] |
348 | 348 | ((get-in f.tools.filesystem/definitions ["eca_move_file" :handler]) |
|
353 | 353 | (is (match? |
354 | 354 | {:error false |
355 | 355 | :contents [{:type :text |
356 | | - :content (format "Successfully moved %s to %s" |
| 356 | + :text (format "Successfully moved %s to %s" |
357 | 357 | (h/file-path "/foo/bar/some_file.clj") |
358 | 358 | (h/file-path "/foo/bar/other_file.clj"))}]} |
359 | 359 | (with-redefs [fs/exists? (fn [path] (not (string/includes? path "other_file.clj"))) |
|
0 commit comments