diff --git a/src/metabase/query_processor/middleware/cache.clj b/src/metabase/query_processor/middleware/cache.clj index 7ef5f0a11b9b1217a9ecdff597b12099a07b6750..a10f499683e46bb0295d2426bceb0bee2c94d109 100644 --- a/src/metabase/query_processor/middleware/cache.clj +++ b/src/metabase/query_processor/middleware/cache.clj @@ -105,7 +105,6 @@ ([] (rf)) ([result] - ;; TODO - what about the final result? Are we ignoring it completely? (a/close! in-chan) (let [duration-ms (- (System/currentTimeMillis) start-time)] (log/info (trs "Query took {0} to run; miminum for cache eligibility is {1}" diff --git a/test/metabase/query_processor/middleware/cache_test.clj b/test/metabase/query_processor/middleware/cache_test.clj index dc17f089fee30d676674f86546c244d1c6eb9dd1..22b50089ec0cd37881ddb8a256728e6a15a85c5e 100644 --- a/test/metabase/query_processor/middleware/cache_test.clj +++ b/test/metabase/query_processor/middleware/cache_test.clj @@ -104,17 +104,18 @@ (let [orig @save-chan*] (try (reset! save-chan* save-chan) - (let [orig impl/serialize-async] - (with-redefs [impl/serialize-async (fn [& args] - (u/prog1 (apply orig args) - (a/go - (let [result (a/<! (:out-chan <>))] - (when (instance? Throwable result) - (a/>!! save-chan (or (:type (ex-data result)) - ::exception)))))))] + (let [orig (var-get #'cache/cache-results-async!)] + (with-redefs [cache/cache-results-async! (fn [query-hash out-chan] + (a/go + (when-let [result (a/<! out-chan)] + (when (instance? Throwable result) + (a/>!! save-chan (or (:type (ex-data result)) + ::exception))))) + (orig query-hash out-chan))] (u/prog1 (thunk) - (is (= expected-result - (mt/wait-for-result save-chan 500)))))) + (testing "waiting for save" + (is (= expected-result + (mt/wait-for-result save-chan 1000))))))) (finally (reset! save-chan* orig)))))) @@ -130,8 +131,9 @@ (try (reset! purge-chan* purge-chan) (u/prog1 (thunk) - (is (= expected-result - (mt/wait-for-result purge-chan 500)))) + (testing "waiting for purge" + (is (= expected-result + (mt/wait-for-result purge-chan 500))))) (finally (reset! purge-chan* orig)))))) (defmacro ^:private wait-for-purge-result {:style/indent 1} [expected-result & body]