|
1 | 1 | (ns refactor-nrepl.rename-file-or-dir-test
|
2 |
| - (:require [clojure.test :refer :all] |
| 2 | + (:require [clojure.test :refer [deftest is]] |
3 | 3 | [refactor-nrepl.core
|
4 | 4 | :refer
|
5 | 5 | [get-ns-component ns-form-from-string]]
|
|
22 | 22 | (def old-package-prefix-dir "com.move.ns_to_be_moved/")
|
23 | 23 |
|
24 | 24 | (deftest returns-list-of-affected-files
|
25 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
26 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
27 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [dependents]) |
| 25 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 26 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 27 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_dependents]) |
28 | 28 | refactor-nrepl.rename-file-or-dir/file-or-symlink-exists? (constantly true)]
|
29 | 29 | (let [res (sut/rename-file-or-dir from-file-path to-file-path ignore-errors?)]
|
30 | 30 | (is (or (list? res) (instance? clojure.lang.Cons res)))
|
31 | 31 | (is (= 4 (count res))))));; currently not tracking :require-macros!!
|
32 | 32 |
|
33 | 33 | (deftest replaces-ns-references-in-dependents
|
34 | 34 | (let [dependents (atom [])]
|
35 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
36 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 35 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 36 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
37 | 37 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
38 | 38 | (fn [deps]
|
39 | 39 | (doseq [[^String path content] deps]
|
|
52 | 52 |
|
53 | 53 | (deftest replaces-fully-qualified-vars-in-dependents
|
54 | 54 | (let [dependents (atom [])]
|
55 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
56 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 55 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 56 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
57 | 57 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
58 | 58 | (fn [deps]
|
59 | 59 | (doseq [[f content] deps]
|
|
72 | 72 | (fn [old new]
|
73 | 73 | (is (= old from-file-path))
|
74 | 74 | (is (= new to-file-path)))
|
75 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
76 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [deps])] |
| 75 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 76 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_deps])] |
77 | 77 | (sut/rename-file-or-dir from-file-path to-file-path ignore-errors?)))
|
78 | 78 |
|
79 | 79 | (deftest replaces-ns-references-in-dependendents-when-moving-dirs
|
80 | 80 | (let [dependents (atom [])]
|
81 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
82 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 81 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 82 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
83 | 83 |
|
84 | 84 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
85 | 85 | (fn [deps]
|
|
98 | 98 | (is (= 'com.moved.ns_to_be_moved imported-ns)))))))
|
99 | 99 |
|
100 | 100 | (deftest returns-list-of-affected-files-when-moving-dirs
|
101 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
102 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
103 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [dependents]) |
| 101 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 102 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 103 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_dependents]) |
104 | 104 | refactor-nrepl.rename-file-or-dir/file-or-symlink-exists? (constantly true)]
|
105 | 105 | (let [res (sut/rename-file-or-dir from-dir-path to-dir-path ignore-errors?)]
|
106 | 106 | (is (seq? res))
|
107 | 107 | (is (= 8 (count res))))))
|
108 | 108 |
|
109 | 109 | (deftest replaces-fully-qualified-vars-in-dependents-when-moving-dirs
|
110 | 110 | (let [dependents (atom [])]
|
111 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
112 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 111 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 112 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
113 | 113 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
114 | 114 | (fn [deps]
|
115 | 115 | (doseq [[f content] deps]
|
|
128 | 128 | (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file!
|
129 | 129 | (fn [old new]
|
130 | 130 | (swap! files conj [old new]))
|
131 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
132 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [deps])] |
| 131 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 132 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_deps])] |
133 | 133 | (sut/rename-file-or-dir from-dir-path to-dir-path ignore-errors?)
|
134 | 134 | (is (= (count @files) 9))
|
135 | 135 | (doseq [[^String old ^String new] @files]
|
|
139 | 139 | (deftest moves-any-non-clj-files-contained-in-the-dir
|
140 | 140 | (let [files (atom [])]
|
141 | 141 | (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file!
|
142 |
| - (fn [old new] |
| 142 | + (fn [_old new] |
143 | 143 | (swap! files conj new))
|
144 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
145 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [deps])] |
| 144 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 145 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_deps])] |
146 | 146 | (sut/rename-file-or-dir from-dir-path to-dir-path ignore-errors?)
|
147 | 147 | (is (some #(.endsWith ^String % "non_clj_file") @files))
|
148 | 148 | (is (= 4 (count (filter #(.endsWith ^String % ".cljs") @files)))))))
|
|
155 | 155 | (def to-file-path-cljs (.getAbsolutePath (File. "testproject/src/com/move/moved_ns_cljs.cljs")))
|
156 | 156 |
|
157 | 157 | (deftest returns-list-of-affected-files-for-cljs
|
158 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
159 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
160 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [dependents]) |
| 158 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 159 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 160 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_dependents]) |
161 | 161 | refactor-nrepl.rename-file-or-dir/file-or-symlink-exists? (constantly true)]
|
162 | 162 | (let [res (sut/rename-file-or-dir from-file-path-cljs to-file-path-cljs ignore-errors?)]
|
163 | 163 | (is (or (list? res) (instance? clojure.lang.Cons res)))
|
164 | 164 | (is (= 4 (count res))))))
|
165 | 165 |
|
166 | 166 | (deftest replaces-ns-references-in-dependent-for-cljs
|
167 | 167 | (let [dependents (atom [])]
|
168 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
169 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 168 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 169 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
170 | 170 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
171 | 171 | (fn [deps]
|
172 |
| - (doseq [[f content] deps] |
| 172 | + (doseq [[_f content] deps] |
173 | 173 | (swap! dependents conj content)))]
|
174 | 174 | (sut/rename-file-or-dir from-file-path-cljs to-file-path-cljs ignore-errors?)
|
175 | 175 | (doseq [content @dependents
|
|
181 | 181 |
|
182 | 182 | (deftest replaces-fully-qualified-vars-in-dependents-for-cljs
|
183 | 183 | (let [dependents (atom [])]
|
184 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
185 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 184 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 185 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
186 | 186 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
187 | 187 | (fn [deps]
|
188 | 188 | (doseq [[f content] deps]
|
|
201 | 201 | (fn [old new]
|
202 | 202 | (is (= old from-file-path-cljs))
|
203 | 203 | (is (= new to-file-path-cljs)))
|
204 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
205 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [deps])] |
| 204 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 205 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_deps])] |
206 | 206 | (sut/rename-file-or-dir from-file-path-cljs to-file-path-cljs ignore-errors?)))
|
207 | 207 |
|
208 | 208 | (deftest replaces-ns-references-in-dependendents-when-moving-dirs-for-cljs
|
209 | 209 | (let [dependents (atom [])]
|
210 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
211 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 210 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 211 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
212 | 212 |
|
213 | 213 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
214 | 214 | (fn [deps]
|
|
230 | 230 | (= 'com.moved.ns-to-be-moved required-macro-ns))))))))
|
231 | 231 |
|
232 | 232 | (deftest returns-list-of-affected-files-when-moving-dirs-for-cljs
|
233 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
234 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
235 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [dependents]) |
| 233 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 234 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 235 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_dependents]) |
236 | 236 | refactor-nrepl.rename-file-or-dir/file-or-symlink-exists? (constantly true)]
|
237 | 237 | (let [res (sut/rename-file-or-dir from-dir-path to-dir-path ignore-errors?)]
|
238 | 238 | (is (seq? res))
|
239 | 239 | (is (= 8 (count res))))))
|
240 | 240 |
|
241 | 241 | (deftest replaces-fully-qualified-vars-in-dependents-when-moving-dirs-for-cljs
|
242 | 242 | (let [dependents (atom [])]
|
243 |
| - (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [old new]) |
244 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
| 243 | + (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file! (fn [_old _new]) |
| 244 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
245 | 245 | refactor-nrepl.rename-file-or-dir/update-dependents!
|
246 | 246 | (fn [deps]
|
247 | 247 | (doseq [[f content] deps]
|
|
260 | 260 | (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file!
|
261 | 261 | (fn [old new]
|
262 | 262 | (swap! files conj [old new]))
|
263 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
264 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [deps])] |
| 263 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 264 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_deps])] |
265 | 265 | (sut/rename-file-or-dir from-dir-path to-dir-path ignore-errors?)
|
266 | 266 | (is (= (count @files) 9))
|
267 | 267 | (doseq [[^String old ^String new] @files]
|
|
271 | 271 | (deftest moves-any-non-cljs-files-contained-in-the-dir-for-cljs
|
272 | 272 | (let [files (atom [])]
|
273 | 273 | (with-redefs [refactor-nrepl.rename-file-or-dir/rename-file!
|
274 |
| - (fn [old new] |
| 274 | + (fn [_old new] |
275 | 275 | (swap! files conj new))
|
276 |
| - refactor-nrepl.rename-file-or-dir/update-ns! (fn [path old-ns]) |
277 |
| - refactor-nrepl.rename-file-or-dir/update-dependents! (fn [deps])] |
| 276 | + refactor-nrepl.rename-file-or-dir/update-ns! (fn [_path _old-ns]) |
| 277 | + refactor-nrepl.rename-file-or-dir/update-dependents! (fn [_deps])] |
278 | 278 | (sut/rename-file-or-dir from-dir-path to-dir-path ignore-errors?)
|
279 | 279 | (is (some #(.endsWith ^String % "non_clj_file") @files))
|
280 | 280 | (is (= 4 (count (filter #(.endsWith ^String % ".clj") @files)))))))
|
0 commit comments