From cb8b69500dd558cdbaccdbb9a3ac9bc035544455 Mon Sep 17 00:00:00 2001 From: Martin Kavalar Date: Fri, 25 Aug 2023 16:16:36 +0200 Subject: [PATCH] Add test --- test/nextjournal/clerk/eval_test.clj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/nextjournal/clerk/eval_test.clj b/test/nextjournal/clerk/eval_test.clj index 913592a7a..187ba32ae 100644 --- a/test/nextjournal/clerk/eval_test.clj +++ b/test/nextjournal/clerk/eval_test.clj @@ -227,3 +227,16 @@ (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 @nextjournal.clerk.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))))))) + +