|
5 | 5 | [clojure-lsp.shared :as shared]
|
6 | 6 | [clojure-lsp.test-helper :as h]
|
7 | 7 | [clojure.core.async :as async]
|
8 |
| - [clojure.test :refer [deftest is testing]])) |
| 8 | + [clojure.test :refer [deftest is testing]] |
| 9 | + [matcher-combinators.test :refer [match?]])) |
9 | 10 |
|
10 | 11 | (def findings (atom []))
|
11 | 12 |
|
|
121 | 122 | {:clojure-lsp/unused-public-var
|
122 | 123 | {:level :info
|
123 | 124 | :ignore-test-references? false}}}})
|
124 |
| - (h/assert-submaps [] @findings)) |
| 125 | + (is (match? [] @findings))) |
125 | 126 | (testing "Given a public var foo/bar in a src namespace
|
126 | 127 | And being referenced in a test namespace foo-test
|
127 | 128 | When linter level is :info
|
|
137 | 138 | {:clojure-lsp/unused-public-var
|
138 | 139 | {:level :info
|
139 | 140 | :ignore-test-references? true}}}})
|
140 |
| - (h/assert-submaps |
141 |
| - [{:end-row 1 |
142 |
| - :type :clojure-lsp/unused-public-var |
143 |
| - :level :info |
144 |
| - :filename "/project/src/foo.clj" |
145 |
| - :col 16 |
146 |
| - :uri "file:///project/src/foo.clj" |
147 |
| - :end-col 19 |
148 |
| - :message "Unused public var 'foo/bar'" |
149 |
| - :row 1}] |
150 |
| - @findings))) |
| 141 | + (is (match? [{:end-row 1 |
| 142 | + :type :clojure-lsp/unused-public-var |
| 143 | + :level :info |
| 144 | + :filename (h/file-path "/project/src/foo.clj") |
| 145 | + :col 16 |
| 146 | + :uri (h/file-uri "file:///project/src/foo.clj") |
| 147 | + :end-col 19 |
| 148 | + :message "Unused public var 'foo/bar'" |
| 149 | + :row 1}] |
| 150 | + @findings)))) |
151 | 151 |
|
152 | 152 | (deftest unused-public-var-declared-inside-test-namespace
|
153 | 153 | (swap! (h/db*) merge {:project-root-uri (h/file-uri "file:///project")
|
|
167 | 167 | {:clojure-lsp/unused-public-var
|
168 | 168 | {:level :info
|
169 | 169 | :ignore-test-references? false}}}})
|
170 |
| - (h/assert-submaps |
171 |
| - [{:end-row 1 |
172 |
| - :type :clojure-lsp/unused-public-var |
173 |
| - :level :info |
174 |
| - :filename "/project/test/foo_test.clj" |
175 |
| - :col 21 |
176 |
| - :uri "file:///project/test/foo_test.clj" |
177 |
| - :end-col 27 |
178 |
| - :message "Unused public var 'foo-test/helper'" |
179 |
| - :row 1}] |
180 |
| - @findings)) |
| 170 | + (is (match? [{:end-row 1 |
| 171 | + :type :clojure-lsp/unused-public-var |
| 172 | + :level :info |
| 173 | + :filename (h/file-path "/project/test/foo_test.clj") |
| 174 | + :col 21 |
| 175 | + :uri (h/file-uri "file:///project/test/foo_test.clj") |
| 176 | + :end-col 27 |
| 177 | + :message "Unused public var 'foo-test/helper'" |
| 178 | + :row 1}] |
| 179 | + @findings))) |
181 | 180 | (testing "Given a public var foo-test/helper in a test namespace
|
182 | 181 | When linter level is :info
|
183 | 182 | And the :ignore-test-references? flag is on
|
|
190 | 189 | :config {:linters {:clojure-lsp/unused-public-var
|
191 | 190 | {:level :info
|
192 | 191 | :ignore-test-references? true}}}})
|
193 |
| - (h/assert-submaps |
194 |
| - [{:end-row 1 |
195 |
| - :type :clojure-lsp/unused-public-var |
196 |
| - :level :info |
197 |
| - :filename "/project/test/foo_test.clj" |
198 |
| - :col 21 |
199 |
| - :uri "file:///project/test/foo_test.clj" |
200 |
| - :end-col 27 |
201 |
| - :message "Unused public var 'foo-test/helper'" |
202 |
| - :row 1}] |
203 |
| - @findings)) |
| 192 | + (is (match? [{:end-row 1 |
| 193 | + :type :clojure-lsp/unused-public-var |
| 194 | + :level :info |
| 195 | + :filename (h/file-path "/project/test/foo_test.clj") |
| 196 | + :col 21 |
| 197 | + :uri (h/file-uri "file:///project/test/foo_test.clj") |
| 198 | + :end-col 27 |
| 199 | + :message "Unused public var 'foo-test/helper'" |
| 200 | + :row 1}] |
| 201 | + @findings))) |
204 | 202 | (testing "Given a public var bar-test/baz in a test namespace
|
205 | 203 | When linter level is :info
|
206 | 204 | And the :ignore-test-references? flag is on
|
|
215 | 213 | :config {:linters {:clojure-lsp/unused-public-var
|
216 | 214 | {:level :info
|
217 | 215 | :ignore-test-references? true}}}})
|
218 |
| - (h/assert-submaps [] @findings))) |
| 216 | + (is (match? [] @findings)))) |
219 | 217 |
|
220 | 218 | (deftest lint-project-public-vars
|
221 | 219 | (swap! (h/db*) merge {:project-root-uri (h/file-uri "file:///project")
|
|
0 commit comments