|
126 | 126 | {"path" (h/file-path "/foo/qux/new_file.clj")} |
127 | 127 | {:db {:workspace-folders [{:uri (h/file-uri "file:///foo/bar") :name "bar"}]}})))))) |
128 | 128 |
|
129 | | -(deftest search-files-test |
130 | | - (testing "invalid pattern" |
131 | | - (is (match? |
132 | | - {:error true |
133 | | - :contents [{:type :text |
134 | | - :text "Invalid glob pattern ' '"}]} |
135 | | - (with-redefs [fs/exists? (constantly true)] |
136 | | - ((get-in f.tools.filesystem/definitions ["eca_search_files" :handler]) |
137 | | - {"path" (h/file-path "/project/foo") |
138 | | - "pattern" " "} |
139 | | - {:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}}))))) |
140 | | - (testing "no matches" |
141 | | - (is (match? |
142 | | - {:error true |
143 | | - :contents [{:type :text |
144 | | - :text "No matches found"}]} |
145 | | - (with-redefs [fs/exists? (constantly true) |
146 | | - fs/glob (constantly [])] |
147 | | - ((get-in f.tools.filesystem/definitions ["eca_search_files" :handler]) |
148 | | - {"path" (h/file-path "/project/foo") |
149 | | - "pattern" "foo"} |
150 | | - {:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}}))))) |
151 | | - (testing "matches with wildcard" |
152 | | - (is (match? |
153 | | - {:error false |
154 | | - :contents [{:type :text |
155 | | - :text (str (h/file-path "/project/foo/bar/baz.txt") "\n" |
156 | | - (h/file-path "/project/foo/qux.txt") "\n" |
157 | | - (h/file-path "/project/foo/qux.clj"))}]} |
158 | | - (with-redefs [fs/exists? (constantly true) |
159 | | - fs/glob (constantly [(fs/path (h/file-path "/project/foo/bar/baz.txt")) |
160 | | - (fs/path (h/file-path "/project/foo/qux.txt")) |
161 | | - (fs/path (h/file-path "/project/foo/qux.clj"))])] |
162 | | - ((get-in f.tools.filesystem/definitions ["eca_search_files" :handler]) |
163 | | - {"path" (h/file-path "/project/foo") |
164 | | - "pattern" "**"} |
165 | | - {:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}}))))) |
166 | | - (testing "matches without wildcard" |
167 | | - (is (match? |
168 | | - {:error false |
169 | | - :contents [{:type :text |
170 | | - :text (str (h/file-path "/project/foo/bar/baz.txt") "\n" |
171 | | - (h/file-path "/project/foo/qux.txt"))}]} |
172 | | - (with-redefs [fs/exists? (constantly true) |
173 | | - fs/glob (constantly [(fs/path (h/file-path "/project/foo/bar/baz.txt")) |
174 | | - (fs/path (h/file-path "/project/foo/qux.txt"))])] |
175 | | - ((get-in f.tools.filesystem/definitions ["eca_search_files" :handler]) |
176 | | - {"path" (h/file-path "/project/foo") |
177 | | - "pattern" ".txt"} |
178 | | - {:db {:workspace-folders [{:uri (h/file-uri "file:///project/foo") :name "foo"}]}})))))) |
179 | | - |
180 | 129 | (deftest grep-test |
181 | 130 | (testing "invalid pattern" |
182 | 131 | (is (match? |
|
0 commit comments