Skip to content

Commit

Permalink
Terminate when vcr playback finds a response, closes #181
Browse files Browse the repository at this point in the history
  • Loading branch information
oliyh committed Jul 22, 2023
1 parent dab610f commit 1220276
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vcr/src/martian/vcr.cljc
Original file line number Diff line number Diff line change
@@ -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])))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1220276

Please sign in to comment.