From 33ddaa74b6863735cc9c3208564dccf7e2d4a902 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 8 Jan 2022 12:22:53 -0800 Subject: [PATCH] verify cache entries based on varying parameter names --- test/honey/cache_test.clj | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/honey/cache_test.clj b/test/honey/cache_test.clj index f7736d4..3830e7f 100644 --- a/test/honey/cache_test.clj +++ b/test/honey/cache_test.clj @@ -77,4 +77,16 @@ {:params {:id 2}}) (sut/format {:select [:*] :from [:table] :where [:= :id :?id]} {:cache cache :params {:id 2}}))) - (is (= 1 (cache-size cache))))) + (is (= 1 (cache-size cache))) + ;; different parameter names create different cache entries: + (is (= (sut/format {:select [:*] :from [:table] :where [:= :id :?x]} + {:cache cache :params {:x 2}}) + (sut/format {:select [:*] :from [:table] :where [:= :id :?y]} + {:cache cache :params {:y 2}}))) + (is (= 3 (cache-size cache))) + ;; swapping parameter names creates different cache entries: + (is (= (sut/format {:select [:*] :from [:table] :where [:and [:= :id :?x] [:= :foo :?y]]} + {:cache cache :params {:x 2 :y 3}}) + (sut/format {:select [:*] :from [:table] :where [:and [:= :id :?y] [:= :foo :?x]]} + {:cache cache :params {:x 3 :y 2}}))) + (is (= 5 (cache-size cache)))))