Skip to content

Commit eceb1a7

Browse files
committed
Fix test
1 parent 7962cf3 commit eceb1a7

File tree

2 files changed

+67
-68
lines changed

2 files changed

+67
-68
lines changed

src/eca/features/commands.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
[eca.features.prompt :as f.prompt]
1111
[eca.features.tools.mcp :as f.mcp]
1212
[eca.llm-api :as llm-api]
13-
[eca.logger :as logger]
1413
[eca.messenger :as messenger]
1514
[eca.secrets :as secrets]
1615
[eca.shared :as shared :refer [multi-str update-some]])

test/eca/features/tools/filesystem_test.clj

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -378,78 +378,78 @@
378378
((get-in f.tools.filesystem/definitions ["eca_move_file" :handler])
379379
{"source" (h/file-path "/foo/bar/some_file.clj")
380380
"destination" (h/file-path "/foo/bar/other_file.clj")}
381-
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}})))))
381+
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))))
382382

383-
(deftest preview-file-change-test
384-
(testing "Preview does not modify files"
385-
(let [spit-called* (atom false)
386-
original-file-content "line1\nline2\nline3"]
387-
(is (match?
388-
{:error false
389-
:contents [{:type :text
390-
:text (format "Change simulation completed for %s. Original file unchanged - preview only." (h/file-path "/foo/bar/my-file.txt"))}]}
391-
(with-redefs [fs/exists? (constantly true)
392-
fs/readable? (constantly true)
393-
f.tools.filesystem/allowed-path? (constantly true)
394-
slurp (constantly original-file-content)
395-
spit (fn [& _] (reset! spit-called* true))]
396-
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
397-
{"path" (h/file-path "/foo/bar/my-file.txt")
398-
"original_content" "line2"
399-
"new_content" "modified line2"}
400-
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
383+
(deftest preview-file-change-test
384+
(testing "Preview does not modify files"
385+
(let [spit-called* (atom false)
386+
original-file-content "line1\nline2\nline3"]
387+
(is (match?
388+
{:error false
389+
:contents [{:type :text
390+
:text (format "Change simulation completed for %s. Original file unchanged - preview only." (h/file-path "/foo/bar/my-file.txt"))}]}
391+
(with-redefs [fs/exists? (constantly true)
392+
fs/readable? (constantly true)
393+
f.tools.filesystem/allowed-path? (constantly true)
394+
slurp (constantly original-file-content)
395+
spit (fn [& _] (reset! spit-called* true))]
396+
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
397+
{"path" (h/file-path "/foo/bar/my-file.txt")
398+
"original_content" "line2"
399+
"new_content" "modified line2"}
400+
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
401401
;; Verify that spit was never called (no file modification)
402-
(is (false? @spit-called*))))
402+
(is (false? @spit-called*))))
403403

404-
(testing "Preview handles content not found"
405-
(let [spit-called* (atom false)]
406-
(is (match?
407-
{:error true
408-
:contents [{:type :text
409-
:text (format "Original content not found in %s" (h/file-path "/foo/bar/my-file.txt"))}]}
410-
(with-redefs [fs/exists? (constantly true)
411-
fs/readable? (constantly true)
412-
f.tools.filesystem/allowed-path? (constantly true)
413-
slurp (constantly "line1\nline2\nline3")
414-
spit (fn [& _] (reset! spit-called* true))]
415-
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
416-
{"path" (h/file-path "/foo/bar/my-file.txt")
417-
"original_content" "notfound"
418-
"new_content" "new"}
419-
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
404+
(testing "Preview handles content not found"
405+
(let [spit-called* (atom false)]
406+
(is (match?
407+
{:error true
408+
:contents [{:type :text
409+
:text (format "Original content not found in %s" (h/file-path "/foo/bar/my-file.txt"))}]}
410+
(with-redefs [fs/exists? (constantly true)
411+
fs/readable? (constantly true)
412+
f.tools.filesystem/allowed-path? (constantly true)
413+
slurp (constantly "line1\nline2\nline3")
414+
spit (fn [& _] (reset! spit-called* true))]
415+
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
416+
{"path" (h/file-path "/foo/bar/my-file.txt")
417+
"original_content" "notfound"
418+
"new_content" "new"}
419+
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
420420
;; Verify that spit was never called even for error case
421-
(is (false? @spit-called*))))
421+
(is (false? @spit-called*))))
422422

423-
(testing "Preview succeeds for new file creation (empty original content)"
424-
(let [spit-called* (atom false)]
425-
(is (match?
426-
{:error false
427-
:contents [{:type :text
428-
:text (format "New file creation simulation completed for %s. File will be created - preview only." (h/file-path "/foo/bar/new-file.txt"))}]}
429-
(with-redefs [fs/exists? (constantly false) ; File doesn't exist
430-
f.tools.filesystem/allowed-path? (constantly true)
431-
spit (fn [& _] (reset! spit-called* true))]
432-
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
433-
{"path" (h/file-path "/foo/bar/new-file.txt")
434-
"original_content" "" ; Empty for new file
435-
"new_content" "New file content"}
436-
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
423+
(testing "Preview succeeds for new file creation (empty original content)"
424+
(let [spit-called* (atom false)]
425+
(is (match?
426+
{:error false
427+
:contents [{:type :text
428+
:text (format "New file creation simulation completed for %s. File will be created - preview only." (h/file-path "/foo/bar/new-file.txt"))}]}
429+
(with-redefs [fs/exists? (constantly false) ; File doesn't exist
430+
f.tools.filesystem/allowed-path? (constantly true)
431+
spit (fn [& _] (reset! spit-called* true))]
432+
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
433+
{"path" (h/file-path "/foo/bar/new-file.txt")
434+
"original_content" "" ; Empty for new file
435+
"new_content" "New file content"}
436+
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
437437
;; Verify that spit was never called (no file modification)
438-
(is (false? @spit-called*))))
438+
(is (false? @spit-called*))))
439439

440-
(testing "Preview fails when trying to find content in non-existent file"
441-
(let [spit-called* (atom false)]
442-
(is (match?
443-
{:error true
444-
:contents [{:type :text
445-
:text (format "Preview error for %s: For new files, original_content must be empty string (\"\"). Use markdown blocks during exploration, then eca_preview_file_change for final implementation only." (h/file-path "/foo/bar/missing-file.txt"))}]}
446-
(with-redefs [fs/exists? (constantly false) ; File doesn't exist
447-
f.tools.filesystem/allowed-path? (constantly true)
448-
spit (fn [& _] (reset! spit-called* true))]
449-
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
450-
{"path" (h/file-path "/foo/bar/missing-file.txt")
451-
"original_content" "some content" ; Non-empty for non-existent file
452-
"new_content" "replacement content"}
453-
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
440+
(testing "Preview fails when trying to find content in non-existent file"
441+
(let [spit-called* (atom false)]
442+
(is (match?
443+
{:error true
444+
:contents [{:type :text
445+
:text (format "Preview error for %s: For new files, original_content must be empty string (\"\"). Use markdown blocks during exploration, then eca_preview_file_change for final implementation only." (h/file-path "/foo/bar/missing-file.txt"))}]}
446+
(with-redefs [fs/exists? (constantly false) ; File doesn't exist
447+
f.tools.filesystem/allowed-path? (constantly true)
448+
spit (fn [& _] (reset! spit-called* true))]
449+
((get-in f.tools.filesystem/definitions ["eca_preview_file_change" :handler])
450+
{"path" (h/file-path "/foo/bar/missing-file.txt")
451+
"original_content" "some content" ; Non-empty for non-existent file
452+
"new_content" "replacement content"}
453+
{:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "foo"}]}}))))
454454
;; Verify that spit was never called
455-
(is (false? @spit-called*))))))
455+
(is (false? @spit-called*)))))

0 commit comments

Comments
 (0)