From 1220276d065c1e23950baae386de6b7a2937abe1 Mon Sep 17 00:00:00 2001 From: Oliver Hine Date: Sat, 22 Jul 2023 15:00:48 +0100 Subject: [PATCH] Terminate when vcr playback finds a response, closes #181 --- vcr/src/martian/vcr.cljc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vcr/src/martian/vcr.cljc b/vcr/src/martian/vcr.cljc index 90f74da..011a6a1 100644 --- a/vcr/src/martian/vcr.cljc +++ b/vcr/src/martian/vcr.cljc @@ -1,7 +1,9 @@ (ns martian.vcr (:require #?@(:clj [[clojure.java.io :as io] [clojure.edn :as edn] - [fipp.clojure :as fipp]]))) + [fipp.clojure :as fipp] + [martian.interceptors :refer [remove-stack]]] + :cljs [[martian.interceptors :refer [remove-stack]]]))) (defmulti persist-response! (fn [opts _ctx] (get-in opts [:store :kind]))) (defmulti load-response (fn [opts _ctx] (get-in opts [:store :kind]))) @@ -89,7 +91,8 @@ :enter (fn [ctx] (let [request-count (inc-counter! counters ctx)] (if-let [response (load-response opts (assoc ctx ::request-count request-count))] - (assoc ctx :response response) + (-> (remove-stack ctx) + (assoc :response response)) (condp = on-missing-response :throw-error (let [message (str "No response stored for request " (request-op ctx) " " (request-key ctx))] (throw #?(:clj (Exception. message)