|
13 | 13 | (-> (Instant/now) .getEpochSecond (* 1000)))
|
14 | 14 |
|
15 | 15 | (defn- create-dummy-cache-file [& [timestamp]]
|
16 |
| - (let [cache-file (io/file docs/cache-file-name)] |
| 16 | + (let [cache-file docs/cache-file] |
17 | 17 | (.. cache-file
|
18 | 18 | getParentFile
|
19 | 19 | mkdirs)
|
|
22 | 22 | (cond-> timestamp (.setLastModified timestamp)))))
|
23 | 23 |
|
24 | 24 | (defn- clojuredocs-test-fixture [f]
|
25 |
| - (with-redefs [docs/cache-file-name "target/clojuredocs/export.edn"] |
| 25 | + (with-redefs [docs/cache-file (io/file "target/clojuredocs/export.edn")] |
26 | 26 | (docs/clean-cache!)
|
27 | 27 | (f)
|
28 | 28 | (docs/clean-cache!)))
|
29 | 29 |
|
30 | 30 | (use-fixtures :each clojuredocs-test-fixture)
|
31 | 31 |
|
32 | 32 | (deftest load-docs-if-not-loaded!-test
|
33 |
| - (let [cache-file (io/file docs/cache-file-name)] |
| 33 | + (let [cache-file docs/cache-file] |
34 | 34 | (testing "bundled"
|
35 | 35 | (is (not (.exists cache-file)))
|
36 | 36 | (is (empty? @docs/cache))
|
|
66 | 66 | (docs/clean-cache!))))
|
67 | 67 |
|
68 | 68 | (deftest update-cache!-no-cache-file-test
|
69 |
| - (let [cache-file (io/file docs/cache-file-name)] |
| 69 | + (let [cache-file docs/cache-file] |
70 | 70 | (testing "accessible to remote export.edn"
|
71 | 71 | (is (not (.exists cache-file)))
|
72 | 72 | (is (empty? @docs/cache))
|
|
86 | 86 | (is (empty? @docs/cache)))))
|
87 | 87 |
|
88 | 88 | (deftest update-cache!-non-existing-url-test
|
89 |
| - (let [cache-file (io/file docs/cache-file-name)] |
| 89 | + (let [cache-file docs/cache-file] |
90 | 90 | (is (not (.exists cache-file)))
|
91 | 91 | (is (empty? @docs/cache))
|
92 | 92 | (is (thrown? Exception (docs/update-cache! "file:/not/existing/file.edn")))
|
93 | 93 | (is (not (.exists cache-file)))
|
94 | 94 | (is (empty? @docs/cache))))
|
95 | 95 |
|
96 | 96 | (deftest update-cache!-existing-cache-file-test
|
97 |
| - (let [cache-file (io/file docs/cache-file-name)] |
| 97 | + (let [cache-file docs/cache-file] |
98 | 98 | (testing "no cached documentation"
|
99 | 99 | (create-dummy-cache-file now)
|
100 | 100 | (reset! docs/cache {})
|
|
119 | 119 | (deftest clean-cache!-test
|
120 | 120 | (create-dummy-cache-file)
|
121 | 121 | (reset! docs/cache {:dummy "not-empty-dummy-data"})
|
122 |
| - (let [cache-file (io/file docs/cache-file-name)] |
| 122 | + (let [cache-file docs/cache-file] |
123 | 123 | (is (.exists cache-file))
|
124 | 124 | (is (seq @docs/cache))
|
125 | 125 | (docs/clean-cache!)
|
|
0 commit comments