From 346cdad73da3a27ab08a65a5e48bc7b72b2e872e Mon Sep 17 00:00:00 2001 From: Josh Glover Date: Thu, 15 Feb 2024 09:33:33 +0100 Subject: [PATCH] Move sleeps before writes in caching tests --- test/quickblog/api_test.clj | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/quickblog/api_test.clj b/test/quickblog/api_test.clj index d6fc8c8..d4b2567 100644 --- a/test/quickblog/api_test.clj +++ b/test/quickblog/api_test.clj @@ -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"])]