Skip to content

Commit 70b8313

Browse files
committed
Fix tests
1 parent 31a835a commit 70b8313

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

src/eca/features/chat.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,9 @@
874874
config)
875875
image-contents (->> refined-contexts
876876
(filter #(= :image (:type %))))
877-
expanded-prompt-contexts (when-let [contexts-str (-> (f.context/contexts-str-from-prompt message db)
878-
(f.prompt/contexts-str repo-map*))]
877+
expanded-prompt-contexts (when-let [contexts-str (some-> (f.context/contexts-str-from-prompt message db)
878+
seq
879+
(f.prompt/contexts-str repo-map*))]
879880
[{:type :text :text contexts-str}])
880881
user-messages [{:role "user" :content (concat [{:type :text :text message}]
881882
expanded-prompt-contexts

src/eca/shared.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
The cache key includes the file's last-modified timestamp, so the cache
163163
automatically invalidates when the file changes."
164164
[f]
165-
(let [mf (memoize/memo (fn [file mtime & args]
165+
(let [mf (memoize/memo (fn [file _mtime & args]
166166
(apply f file args)))
167167
safe-mtime (fn [file]
168168
(try

test/eca/features/context_test.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{:type "file" :path (h/file-path (str root "/dir/nested.txt"))}
4242
{:type "file" :path (h/file-path (str root "/bar.txt"))}
4343
{:type "mcpResource" :uri "mcp://r1"}]
44-
(f.context/all-contexts nil (h/db*) (h/config)))))))
44+
(f.context/all-contexts nil false (h/db*) (h/config)))))))
4545

4646
(testing "respects the query by limiting glob results"
4747
(h/reset-components!)
@@ -57,7 +57,7 @@
5757
fs/canonicalize identity
5858
f.index/filter-allowed (fn [file-paths _root _config] file-paths)
5959
f.mcp/all-resources (fn [_db] [])]
60-
(let [result (f.context/all-contexts "foo" (h/db*) {})]
60+
(let [result (f.context/all-contexts "foo" false (h/db*) {})]
6161
;; Should include foo.txt but not bar.txt
6262
(is (some #(= {:type "file" :path (str root "/foo.txt")} %) result))
6363
(is (not (some #(= {:type "file" :path (str root "/bar.txt")} %) result)))))))
@@ -85,7 +85,7 @@
8585
fs/canonicalize identity
8686
f.index/filter-allowed (fn [file-paths _root _config] file-paths)
8787
f.mcp/all-resources (fn [_db] [])]
88-
(let [result (f.context/all-contexts nil (h/db*) {})]
88+
(let [result (f.context/all-contexts nil false (h/db*) {})]
8989
;; Root directories present
9090
(is (some #(= {:type "directory" :path root1} %) result))
9191
(is (some #(= {:type "directory" :path root2} %) result))
@@ -107,7 +107,7 @@
107107
f.index/filter-allowed (fn [files _root _config] files)]
108108
(let [db* (atom {:workspace-folders [{:uri (h/file-uri "file:///fake/repo")}]})
109109
config {}
110-
results (f.context/all-contexts "readme" db* config)
110+
results (f.context/all-contexts "readme" false db* config)
111111
file-paths (->> results (filter #(= "file" (:type %))) (map :path) set)]
112112
(is (contains? file-paths readme)))))))
113113

@@ -128,7 +128,7 @@
128128
fs/canonicalize identity
129129
f.index/filter-allowed (fn [file-paths _root _config] file-paths)
130130
f.mcp/all-resources (fn [_] [])]
131-
(let [result (f.context/all-contexts "./src" db* {})]
131+
(let [result (f.context/all-contexts "./src" false db* {})]
132132
;; Root directory present
133133
(is (some #(= {:type "directory" :path root} %) result))
134134
;; Entries mapped from the relative listing
@@ -154,7 +154,7 @@
154154
fs/canonicalize identity
155155
f.index/filter-allowed (fn [file-paths _root _config] file-paths)
156156
f.mcp/all-resources (fn [_] [])]
157-
(let [result (f.context/all-contexts "./missing/file" db* {})]
157+
(let [result (f.context/all-contexts "./missing/file" false db* {})]
158158
;; Root directory present
159159
(is (some #(= {:type "directory" :path root} %) result))
160160
;; Entries mapped from the parent listing
@@ -179,7 +179,7 @@
179179
fs/canonicalize identity
180180
f.index/filter-allowed (fn [file-paths _root _config] file-paths)
181181
f.mcp/all-resources (fn [_] [])]
182-
(let [result (f.context/all-contexts "~" db* {})]
182+
(let [result (f.context/all-contexts "~" false db* {})]
183183
;; Root directory present
184184
(is (some #(= {:type "directory" :path root} %) result))
185185
;; Entries from home listing

test/eca/features/prompt_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(is (string/includes? result "<rules description=\"Rules defined by user\">"))
2020
(is (string/includes? result "<rule name=\"rule1\">First rule</rule>"))
2121
(is (string/includes? result "<rule name=\"rule2\">Second rule</rule>"))
22-
(is (string/includes? result "<contexts description=\"Manually provided by user, usually when provided user knows that your task is related to those files, so consider reliying on it, if not enough, use tools to read/gather any extra files/contexts.\">"))
22+
(is (string/includes? result "<contexts description=\"Manually Provided by user. Their content is current and accurate. You MUST use this information first before using tools to read them.\">"))
2323
(is (string/includes? result "<file path=\"foo.clj\">(ns foo)</file>"))
2424
(is (string/includes? result "<file partial=true path=\"bar.clj\">...\n(def a 1)\n...</file>"))
2525
(is (string/includes? result "<repoMap description=\"Workspaces structure in a tree view, spaces represent file hierarchy\" >TREE</repoMap>"))
@@ -40,7 +40,7 @@
4040
(is (string/includes? result "<rules description=\"Rules defined by user\">"))
4141
(is (string/includes? result "<rule name=\"rule1\">First rule</rule>"))
4242
(is (string/includes? result "<rule name=\"rule2\">Second rule</rule>"))
43-
(is (string/includes? result "<contexts description=\"Manually provided by user, usually when provided user knows that your task is related to those files, so consider reliying on it, if not enough, use tools to read/gather any extra files/contexts.\">"))
43+
(is (string/includes? result "<contexts description=\"Manually Provided by user. Their content is current and accurate. You MUST use this information first before using tools to read them.\">"))
4444
(is (string/includes? result "<file path=\"foo.clj\">(ns foo)</file>"))
4545
(is (string/includes? result "<file partial=true path=\"bar.clj\">...\n(def a 1)\n...</file>"))
4646
(is (string/includes? result "<repoMap description=\"Workspaces structure in a tree view, spaces represent file hierarchy\" >TREE</repoMap>"))

test/eca/secrets_test.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272

273273
;; Mock decrypt-gpg to simulate timeout behavior
274274
(with-redefs [secrets/gpg-available? (constantly true)
275-
secrets/decrypt-gpg (fn [file-path]
275+
secrets/decrypt-gpg (fn [_file-path]
276276
(reset! decrypt-called? true)
277277
;; Simulate timeout by returning nil
278278
nil)]
@@ -619,9 +619,9 @@
619619
(spit temp-path "machine api.openai.com\nlogin apikey\npassword sk-super-secret-password-123\n")
620620

621621
;; Mock logger to capture messages
622-
(with-redefs [logger/debug (fn [tag & args]
622+
(with-redefs [logger/debug (fn [_tag & args]
623623
(swap! logged-messages conj (vec args)))
624-
logger/info (fn [tag & args]
624+
logger/info (fn [_tag & args]
625625
(swap! logged-messages conj (vec args)))
626626
secrets/credential-file-paths (constantly [temp-path])]
627627
(let [result (secrets/get-credential "api.openai.com")]
@@ -643,7 +643,7 @@
643643
(spit temp-path "machine api.openai.com\nlogin apikey\npassword sk-secret-key-789\ngarbage!!!!\n")
644644

645645
;; Mock logger to capture messages
646-
(with-redefs [logger/warn (fn [tag & args]
646+
(with-redefs [logger/warn (fn [_tag & args]
647647
(swap! logged-messages conj (vec args)))
648648
secrets/credential-file-paths (constantly [temp-path])]
649649
(secrets/get-credential "api.openai.com")
@@ -738,7 +738,7 @@
738738
(Files/setPosixFilePermissions path perms)
739739

740740
;; Mock logger to capture warnings
741-
(with-redefs [logger/warn (fn [tag & args]
741+
(with-redefs [logger/warn (fn [_tag & args]
742742
(swap! warnings conj (vec args)))
743743
secrets/credential-file-paths (constantly [temp-path])]
744744
(secrets/get-credential "api.openai.com")
@@ -773,7 +773,7 @@
773773
(Files/setPosixFilePermissions path perms)
774774

775775
;; Mock logger to capture warnings
776-
(with-redefs [logger/warn (fn [tag & args]
776+
(with-redefs [logger/warn (fn [_tag & args]
777777
(swap! warnings conj (vec args)))
778778
secrets/credential-file-paths (constantly [temp-path])]
779779
(secrets/get-credential "api.openai.com")

0 commit comments

Comments
 (0)