Skip to content

Commit

Permalink
Move sleeps before writes in caching tests
Browse files Browse the repository at this point in the history
jmglov committed Feb 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent f15d959 commit 346cdad
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/quickblog/api_test.clj
Original file line number Diff line number Diff line change
@@ -313,7 +313,6 @@
(Thread/sleep 5)
(write-test-post posts-dir)
(write-test-file assets-dir "asset.txt" "something")
(Thread/sleep 500)
(render)
(let [asset-file (fs/file out-dir "assets" "asset.txt")
mtime (fs/last-modified-time asset-file)]
@@ -357,7 +356,6 @@
(->mtimes (fs/file out-dir "tags")
["clojure.html"]))]
;; Shouldn't rewrite anything when post unmodified
(Thread/sleep 500)
(render)
(doseq [[filename mtime] (merge content-cached clojure-metadata-cached)]
(is (= (map str [filename mtime])
@@ -378,6 +376,17 @@
(write-test-post posts-dir {:title "Changed", :tags #{"not-clojure"}})
(println "Posts:" (map str (fs/glob posts-dir "**")))
(Thread/sleep 500)
(write-test-post posts-dir)
(render)
(doseq [[filename mtime] content-cached]
(is (not= (map str [filename mtime])
(map str [filename (fs/last-modified-time filename)]))))
(doseq [[filename mtime] clojure-metadata-cached]
(is (= (map str [filename mtime])
(map str [filename (fs/last-modified-time filename)]))))
;; Should rewrite everything when metadata modified
(Thread/sleep 500)
(write-test-post posts-dir {:title "Changed", :tags #{"not-clojure"}})
(render)
(doseq [[filename mtime] (merge content-cached metadata-cached)]
(is (not= (map str [filename mtime])
@@ -435,7 +444,6 @@
:tags #{"clojure"}})
(write-test-post posts-dir {:file "random2.md"
:tags #{"something"}})
(Thread/sleep 500)
(let [mtimes (->mtimes out-dir ["atom.xml" "planetclojure.xml"])
_ (render)
mtimes-after (->mtimes out-dir ["atom.xml" "planetclojure.xml"])]
@@ -451,7 +459,6 @@
"clojure2.html"
"clojurescript1.html"}
(post-ids (fs/file out-dir "planetclojure.xml"))))
(Thread/sleep 500)
(let [mtimes (->mtimes out-dir ["atom.xml" "planetclojure.xml"])
_ (render)
mtimes-after (->mtimes out-dir ["atom.xml" "planetclojure.xml"])]

0 comments on commit 346cdad

Please sign in to comment.