Skip to content

Commit 06f34df

Browse files
committed
Fix tests
1 parent a81c6cf commit 06f34df

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

test/eca/features/tools/filesystem_test.clj

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
:content (str (h/file-path "/foo/qux") " is not a valid path")}]}
2020
(with-redefs [fs/canonicalize (constantly (h/file-path "/foo/qux"))
2121
fs/exists? (constantly false)]
22-
((get-in f.tools.filesystem/definitions ["list_directory" :handler])
22+
((get-in f.tools.filesystem/definitions ["eca_list_directory" :handler])
2323
{"path" (h/file-path "/foo/qux")}
2424
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}})))))
2525
(testing "Unallowed dir"
@@ -31,7 +31,7 @@
3131
(h/file-path "/foo/bar/baz"))}]}
3232
(with-redefs [fs/canonicalize (constantly (h/file-path "/foo/qux"))
3333
fs/exists? (constantly true)]
34-
((get-in f.tools.filesystem/definitions ["list_directory" :handler])
34+
((get-in f.tools.filesystem/definitions ["eca_list_directory" :handler])
3535
{"path" (h/file-path "/foo/qux")}
3636
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}})))))
3737
(testing "allowed dir"
@@ -48,7 +48,7 @@
4848
(fs/path (h/file-path "/foo/bar/baz/qux"))])
4949
fs/directory? (fn [path] (not (string/ends-with? (str path) ".clj")))
5050
fs/canonicalize (constantly (h/file-path "/foo/bar/baz"))]
51-
((get-in f.tools.filesystem/definitions ["list_directory" :handler])
51+
((get-in f.tools.filesystem/definitions ["eca_list_directory" :handler])
5252
{"path" (h/file-path "/foo/bar/baz")}
5353
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}}))))))
5454

@@ -61,7 +61,7 @@
6161
(with-redefs [fs/exists? (constantly true)
6262
fs/readable? (constantly false)
6363
f.tools.filesystem/allowed-path? (constantly true)]
64-
((get-in f.tools.filesystem/definitions ["read_file" :handler])
64+
((get-in f.tools.filesystem/definitions ["eca_read_file" :handler])
6565
{"path" (h/file-path "/foo/qux")}
6666
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}})))))
6767
(testing "Readable path"
@@ -73,7 +73,7 @@
7373
fs/exists? (constantly true)
7474
fs/readable? (constantly true)
7575
f.tools.filesystem/allowed-path? (constantly true)]
76-
((get-in f.tools.filesystem/definitions ["read_file" :handler])
76+
((get-in f.tools.filesystem/definitions ["eca_read_file" :handler])
7777
{"path" (h/file-path "/foo/qux")}
7878
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}})))))
7979
(testing "heading a file"
@@ -85,7 +85,7 @@
8585
fs/exists? (constantly true)
8686
fs/readable? (constantly true)
8787
f.tools.filesystem/allowed-path? (constantly true)]
88-
((get-in f.tools.filesystem/definitions ["read_file" :handler])
88+
((get-in f.tools.filesystem/definitions ["eca_read_file" :handler])
8989
{"path" (h/file-path "/foo/qux")
9090
"head" 2}
9191
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}})))))
@@ -98,7 +98,7 @@
9898
fs/exists? (constantly true)
9999
fs/readable? (constantly true)
100100
f.tools.filesystem/allowed-path? (constantly true)]
101-
((get-in f.tools.filesystem/definitions ["read_file" :handler])
101+
((get-in f.tools.filesystem/definitions ["eca_read_file" :handler])
102102
{"path" (h/file-path "/foo/qux")
103103
"tail" 2}
104104
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}}))))))
@@ -112,7 +112,7 @@
112112
(h/file-path "/foo/qux/new_file.clj")
113113
(h/file-path "/foo/bar"))}]}
114114
(with-redefs [f.tools.filesystem/allowed-path? (constantly false)]
115-
((get-in f.tools.filesystem/definitions ["write_file" :handler])
115+
((get-in f.tools.filesystem/definitions ["eca_write_file" :handler])
116116
{"path" (h/file-path "/foo/qux/new_file.clj")}
117117
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "bar"}]}}))))))
118118

@@ -123,7 +123,7 @@
123123
:error true
124124
:content "Invalid glob pattern ' '"}]}
125125
(with-redefs [fs/exists? (constantly true)]
126-
((get-in f.tools.filesystem/definitions ["search_files" :handler])
126+
((get-in f.tools.filesystem/definitions ["eca_search_files" :handler])
127127
{"path" (h/file-path "/project/foo")
128128
"pattern" " "}
129129
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -134,7 +134,7 @@
134134
:content "No matches found"}]}
135135
(with-redefs [fs/exists? (constantly true)
136136
fs/glob (constantly [])]
137-
((get-in f.tools.filesystem/definitions ["search_files" :handler])
137+
((get-in f.tools.filesystem/definitions ["eca_search_files" :handler])
138138
{"path" (h/file-path "/project/foo")
139139
"pattern" "foo"}
140140
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -149,7 +149,7 @@
149149
fs/glob (constantly [(fs/path (h/file-path "/project/foo/bar/baz.txt"))
150150
(fs/path (h/file-path "/project/foo/qux.txt"))
151151
(fs/path (h/file-path "/project/foo/qux.clj"))])]
152-
((get-in f.tools.filesystem/definitions ["search_files" :handler])
152+
((get-in f.tools.filesystem/definitions ["eca_search_files" :handler])
153153
{"path" (h/file-path "/project/foo")
154154
"pattern" "**"}
155155
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -162,7 +162,7 @@
162162
(with-redefs [fs/exists? (constantly true)
163163
fs/glob (constantly [(fs/path (h/file-path "/project/foo/bar/baz.txt"))
164164
(fs/path (h/file-path "/project/foo/qux.txt"))])]
165-
((get-in f.tools.filesystem/definitions ["search_files" :handler])
165+
((get-in f.tools.filesystem/definitions ["eca_search_files" :handler])
166166
{"path" (h/file-path "/project/foo")
167167
"pattern" ".txt"}
168168
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}}))))))
@@ -175,7 +175,7 @@
175175
:content "Invalid content regex pattern ' '"}]}
176176
(with-redefs [fs/exists? (constantly true)
177177
fs/readable? (constantly true)]
178-
((get-in f.tools.filesystem/definitions ["grep" :handler])
178+
((get-in f.tools.filesystem/definitions ["eca_grep" :handler])
179179
{"path" (h/file-path "/project/foo")
180180
"pattern" " "}
181181
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -186,7 +186,7 @@
186186
:content "Invalid file pattern ' '"}]}
187187
(with-redefs [fs/exists? (constantly true)
188188
fs/readable? (constantly true)]
189-
((get-in f.tools.filesystem/definitions ["grep" :handler])
189+
((get-in f.tools.filesystem/definitions ["eca_grep" :handler])
190190
{"path" (h/file-path "/project/foo")
191191
"pattern" ".*"
192192
"include" " "}
@@ -200,7 +200,7 @@
200200
fs/readable? (constantly true)
201201
tools.util/command-available? (fn [command & _args] (= "rg" command))
202202
shell/sh (constantly {:out ""})]
203-
((get-in f.tools.filesystem/definitions ["grep" :handler])
203+
((get-in f.tools.filesystem/definitions ["eca_grep" :handler])
204204
{"path" (h/file-path "/project/foo")
205205
"pattern" ".*"}
206206
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -213,7 +213,7 @@
213213
fs/readable? (constantly true)
214214
tools.util/command-available? (fn [command & _args] (= "rg" command))
215215
shell/sh (constantly {:out "/project/foo/bla.txt\n/project/foo/qux.txt"})]
216-
((get-in f.tools.filesystem/definitions ["grep" :handler])
216+
((get-in f.tools.filesystem/definitions ["eca_grep" :handler])
217217
{"path" (h/file-path "/project/foo")
218218
"pattern" "some-cool-content"}
219219
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -226,7 +226,7 @@
226226
fs/readable? (constantly true)
227227
tools.util/command-available? (fn [command & _args] (= "grep" command))
228228
shell/sh (constantly {:out "/project/foo/bla.txt\n/project/foo/qux.txt"})]
229-
((get-in f.tools.filesystem/definitions ["grep" :handler])
229+
((get-in f.tools.filesystem/definitions ["eca_grep" :handler])
230230
{"path" (h/file-path "/project/foo")
231231
"pattern" "some-cool-content"}
232232
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -244,7 +244,7 @@
244244
fs/directory? (constantly false)
245245
fs/hidden? (constantly false)
246246
fs/file (constantly (ByteArrayInputStream. (.getBytes "some-cool-content")))]
247-
((get-in f.tools.filesystem/definitions ["grep" :handler])
247+
((get-in f.tools.filesystem/definitions ["eca_grep" :handler])
248248
{"path" (h/file-path "/project/foo")
249249
"pattern" "some-cool-content"}
250250
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}}))))))
@@ -258,7 +258,7 @@
258258
(with-redefs [fs/exists? (constantly true)
259259
fs/readable? (constantly false)
260260
f.tools.filesystem/allowed-path? (constantly true)]
261-
((get-in f.tools.filesystem/definitions ["replace_in_file" :handler])
261+
((get-in f.tools.filesystem/definitions ["eca_replace_in_file" :handler])
262262
{"path" (h/file-path "/foo/qux")
263263
"original_content" "some-cool-text"
264264
"new_content" "another-boring-text"}
@@ -272,7 +272,7 @@
272272
fs/readable? (constantly true)
273273
f.tools.filesystem/allowed-path? (constantly true)
274274
slurp (constantly "Hey, here is some-cool-text in this file!")]
275-
((get-in f.tools.filesystem/definitions ["replace_in_file" :handler])
275+
((get-in f.tools.filesystem/definitions ["eca_replace_in_file" :handler])
276276
{"path" (h/file-path "/project/foo/my-file.txt")
277277
"original_content" "other-cool-text"
278278
"new_content" "another-boring-text"}
@@ -288,7 +288,7 @@
288288
f.tools.filesystem/allowed-path? (constantly true)
289289
slurp (constantly "Hey, here is some-cool-text in this file! here as well: some-cool-text")
290290
spit (fn [f content] (swap! file-content* assoc f content))]
291-
((get-in f.tools.filesystem/definitions ["replace_in_file" :handler])
291+
((get-in f.tools.filesystem/definitions ["eca_replace_in_file" :handler])
292292
{"path" (h/file-path "/project/foo/my-file.txt")
293293
"original_content" "some-cool-text"
294294
"new_content" "another-boring-text"}
@@ -307,7 +307,7 @@
307307
f.tools.filesystem/allowed-path? (constantly true)
308308
slurp (constantly "Hey, here is some-cool-text in this file! here as well: some-cool-text")
309309
spit (fn [f content] (swap! file-content* assoc f content))]
310-
((get-in f.tools.filesystem/definitions ["replace_in_file" :handler])
310+
((get-in f.tools.filesystem/definitions ["eca_replace_in_file" :handler])
311311
{"path" (h/file-path "/project/foo/my-file.txt")
312312
"original_content" "some-cool-text"
313313
"new_content" "another-boring-text"
@@ -325,7 +325,7 @@
325325
:content (format "%s is not a valid path" (h/file-path "/foo/qux"))}]}
326326
(with-redefs [fs/exists? (constantly false)
327327
f.tools.filesystem/allowed-path? (constantly true)]
328-
((get-in f.tools.filesystem/definitions ["move_file" :handler])
328+
((get-in f.tools.filesystem/definitions ["eca_move_file" :handler])
329329
{"source" (h/file-path "/foo/qux")}
330330
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar/baz") :name "foo"}]}})))))
331331
(testing "Destination already exists"
@@ -335,7 +335,7 @@
335335
:content (format "Path %s already exists" (h/file-path "/foo/bar/other_file.clj"))}]}
336336
(with-redefs [fs/exists? (constantly true)
337337
f.tools.filesystem/allowed-path? (constantly true)]
338-
((get-in f.tools.filesystem/definitions ["move_file" :handler])
338+
((get-in f.tools.filesystem/definitions ["eca_move_file" :handler])
339339
{"source" (h/file-path "/foo/bar/some_file.clj")
340340
"destination" (h/file-path "/foo/bar/other_file.clj")}
341341
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}})))))
@@ -349,7 +349,7 @@
349349
(with-redefs [fs/exists? (fn [path] (not (string/includes? path "other_file.clj")))
350350
f.tools.filesystem/allowed-path? (constantly true)
351351
fs/move (constantly true)]
352-
((get-in f.tools.filesystem/definitions ["move_file" :handler])
352+
((get-in f.tools.filesystem/definitions ["eca_move_file" :handler])
353353
{"source" (h/file-path "/foo/bar/some_file.clj")
354354
"destination" (h/file-path "/foo/bar/other_file.clj")}
355355
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))))

test/eca/features/tools/shell_test.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
:error true
1515
:content (format "working directory %s does not exist" (h/file-path "/baz"))}]}
1616
(with-redefs [fs/exists? (constantly false)]
17-
((get-in f.tools.shell/definitions ["shell_command" :handler])
17+
((get-in f.tools.shell/definitions ["eca_shell_command" :handler])
1818
{"command" "ls -lh"
1919
"working_directory" (h/file-path "/baz")}
2020
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -25,7 +25,7 @@
2525
:content "Command failed with exit code 1: Some error"}]}
2626
(with-redefs [fs/exists? (constantly true)
2727
shell/sh (constantly {:exit 1 :err "Some error"})]
28-
((get-in f.tools.shell/definitions ["shell_command" :handler])
28+
((get-in f.tools.shell/definitions ["eca_shell_command" :handler])
2929
{"command" "ls -lh"}
3030
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
3131
(testing "command succeeds"
@@ -35,7 +35,7 @@
3535
:content "Some text"}]}
3636
(with-redefs [fs/exists? (constantly true)
3737
shell/sh (constantly {:exit 0 :out "Some text" :err "Other text"})]
38-
((get-in f.tools.shell/definitions ["shell_command" :handler])
38+
((get-in f.tools.shell/definitions ["eca_shell_command" :handler])
3939
{"command" "ls -lh"}
4040
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
4141
(testing "command succeeds with different working directory"
@@ -45,7 +45,7 @@
4545
:content "Some text"}]}
4646
(with-redefs [fs/exists? (constantly true)
4747
shell/sh (constantly {:exit 0 :out "Some text" :err "Other text"})]
48-
((get-in f.tools.shell/definitions ["shell_command" :handler])
48+
((get-in f.tools.shell/definitions ["eca_shell_command" :handler])
4949
{"command" "ls -lh"
5050
"working_directory" (h/file-path "/project/foo/src")}
5151
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))
@@ -56,7 +56,7 @@
5656
:content "Some text"}]}
5757
(with-redefs [fs/exists? (constantly true)
5858
shell/sh (constantly {:exit 0 :out "Some text" :err "Other text"})]
59-
((get-in f.tools.shell/definitions ["shell_command" :handler])
59+
((get-in f.tools.shell/definitions ["eca_shell_command" :handler])
6060
{"command" "rm -r /project/foo/src"}
6161
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}
6262
:config {:nativeTools {:shell {:enabled true
@@ -67,7 +67,7 @@
6767
:error true
6868
:content "Cannot run command 'rm' because it is excluded by eca config."}]}
6969
(with-redefs [fs/exists? (constantly true)]
70-
((get-in f.tools.shell/definitions ["shell_command" :handler])
70+
((get-in f.tools.shell/definitions ["eca_shell_command" :handler])
7171
{"command" "rm -r /project/foo/src"}
7272
{:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}
7373
:config {:nativeTools {:shell {:enabled true

test/eca/features/tools_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
:description (format "Only in %s" (h/file-path "/path/to/project/foo"))
3939
:parameters some?
4040
:source :native}])
41-
(with-redefs [f.tools.filesystem/definitions {"list_directory" {:description "Only in $workspaceRoots"
42-
:parameters {}}}]
41+
(with-redefs [f.tools.filesystem/definitions {"eca_list_directory" {:description "Only in $workspaceRoots"
42+
:parameters {}}}]
4343
(f.tools/all-tools {:workspace-folders [{:name "foo" :uri (h/file-uri "file:///path/to/project/foo")}]}
4444
{:nativeTools {:filesystem {:enabled true}}}))))))

0 commit comments

Comments
 (0)