|
| 1 | +(ns eca.features.tools.mcp.clojure-mcp-test |
| 2 | + (:require |
| 3 | + [clojure.string :as string] |
| 4 | + [clojure.test :refer [deftest is testing]] |
| 5 | + [eca.features.tools :as f.tools] |
| 6 | + [matcher-combinators.test :refer [match?]])) |
| 7 | + |
| 8 | +(def ^:private example-diff |
| 9 | + (string/join "\n" ["--- original.txt" |
| 10 | + "+++ revised.txt" |
| 11 | + "@@ -1,1 +1,2 @@" |
| 12 | + "-a" |
| 13 | + "+b" |
| 14 | + "+c"])) |
| 15 | + |
| 16 | +(deftest tool-call-details-after-invocation-clojure-mcp-clojure-edit-test |
| 17 | + (testing "Tool call details for the Clojure MCP clojure_edit tool" |
| 18 | + (is (match? {:type :fileChange |
| 19 | + :path "/home/alice/my-org/my-proj/project.clj" |
| 20 | + :linesAdded 2 |
| 21 | + :linesRemoved 1 |
| 22 | + :diff example-diff} |
| 23 | + (f.tools/tool-call-details-after-invocation |
| 24 | + :clojure_edit |
| 25 | + {"file_path" "/home/alice/my-org/my-proj/project.clj" |
| 26 | + "form_identifier" "a" |
| 27 | + "form_type" "atom" |
| 28 | + "operation" "replace" |
| 29 | + "content" "b\nc"} |
| 30 | + nil |
| 31 | + {:error false :contents [{:type :text :text example-diff}]}))))) |
| 32 | + |
| 33 | +(deftest tool-call-details-after-invocation-clojure-mcp-clojure-edit-replace-sexp-test |
| 34 | + (testing "Tool call details for the Clojure MCP clojure_edit_replace_sexp tool" |
| 35 | + (is (match? {:type :fileChange |
| 36 | + :path "/home/alice/my-org/my-proj/project.clj" |
| 37 | + :linesAdded 2 |
| 38 | + :linesRemoved 1 |
| 39 | + :diff example-diff} |
| 40 | + (f.tools/tool-call-details-after-invocation |
| 41 | + :clojure_edit_replace_sexp |
| 42 | + {"file_path" "/home/alice/my-org/my-proj/project.clj" |
| 43 | + "match_form" "a" |
| 44 | + "new_form" "b\nc" |
| 45 | + "replace_all" false} |
| 46 | + nil |
| 47 | + {:error false :contents [{:type :text :text example-diff}]}))))) |
| 48 | + |
| 49 | +(deftest tool-call-details-after-invocation-clojure-mcp-file-edit-test |
| 50 | + (testing "Tool call details for the Clojure MCP file_edit tool" |
| 51 | + (is (match? {:type :fileChange |
| 52 | + :path "/home/alice/my-org/my-proj/project.clj" |
| 53 | + :linesAdded 2 |
| 54 | + :linesRemoved 1 |
| 55 | + :diff example-diff} |
| 56 | + (f.tools/tool-call-details-after-invocation |
| 57 | + :file_edit |
| 58 | + {"file_path" "/home/alice/my-org/my-proj/project.clj" |
| 59 | + "old_string" "a" |
| 60 | + "new_string" "b\nc"} |
| 61 | + nil |
| 62 | + {:error false :contents [{:type :text :text example-diff}]}))))) |
| 63 | + |
| 64 | +(deftest tool-call-details-after-invocation-clojure-mcp-file-write-test |
| 65 | + (testing "Tool call details for the Clojure MCP file_write tool" |
| 66 | + (is (match? {:type :fileChange |
| 67 | + :path "/home/alice/my-org/my-proj/project.clj" |
| 68 | + :linesAdded 2 |
| 69 | + :linesRemoved 1 |
| 70 | + :diff example-diff} |
| 71 | + (f.tools/tool-call-details-after-invocation |
| 72 | + :file_write |
| 73 | + {"file_path" "/home/alice/my-org/my-proj/project.clj" |
| 74 | + "content" "my-content"} |
| 75 | + nil |
| 76 | + {:error false |
| 77 | + :contents [{:type :text |
| 78 | + :text (string/join "\n" |
| 79 | + ["Clojure file updated: /home/alice/my-org/my-proj/project.clj" |
| 80 | + "Changes:" example-diff])}]}))))) |
0 commit comments