Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mk committed Aug 25, 2023
1 parent d5af6cc commit 5136656
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/nextjournal/clerk/eval_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[nextjournal.clerk.eval :as eval]
[nextjournal.clerk.parser :as parser]
[nextjournal.clerk.view :as view]
[nextjournal.clerk.viewer :as viewer]))
[nextjournal.clerk.viewer :as viewer]
[nextjournal.clerk.webserver :as webserver]))

(deftest eval-string
(testing "hello 42"
Expand Down Expand Up @@ -227,3 +228,15 @@
(testing "class is not cachable"
(is (not (#'eval/cachable-value? java.lang.String)))
(is (not (#'eval/cachable-value? {:foo java.lang.String})))))

(deftest show!-test
(testing "in-memory cache is preserved when exception is thrown (#549)"
(let [code "{:f inc :n (rand-int 100000)}"
get-result #(:blob->result @webserver/!doc)]
(clerk/show! (java.io.StringReader. code))
(let [result-first-run (get-result)]
(try (clerk/show! (java.io.StringReader. (str code " (throw (ex-info \"boom\" {}))")))
(catch Exception _ nil))
(clerk/show! (java.io.StringReader. code))
(is (= result-first-run (get-result)))))))

0 comments on commit 5136656

Please sign in to comment.