diff --git a/src/elin/function/storage/test.clj b/src/elin/function/storage/test.clj index 7393a6db..b862240c 100644 --- a/src/elin/function/storage/test.clj +++ b/src/elin/function/storage/test.clj @@ -1,17 +1,24 @@ (ns elin.function.storage.test (:require [elin.protocol.storage :as e.p.storage] - [elin.schema.handler :as e.s.handler] + [elin.schema.component :as e.s.component] [malli.core :as m])) (def ^:private last-test-query-key ::last-test-query) +(def ^:private last-failed-tests-key ::last-failed-tests) -(m/=> set-last-test-query [:=> [:cat e.s.handler/?Elin string?] :nil]) -(defn set-last-test-query - [{:component/keys [session-storage]} query] - (e.p.storage/set session-storage last-test-query-key query)) +(m/=> set* [:=> [:cat keyword? e.s.component/?Storage string?] :nil]) +(defn- set* + [storage-key storage query] + (e.p.storage/set storage storage-key query)) -(m/=> get-last-test-query [:=> [:cat e.s.handler/?Elin] string?]) -(defn get-last-test-query - [{:component/keys [session-storage]}] - (e.p.storage/get session-storage last-test-query-key)) +(m/=> get* [:=> [:cat keyword? e.s.component/?Storage] string?]) +(defn- get* + [storage-key storage] + (e.p.storage/get storage storage-key)) + +(def set-last-test-query (partial set* last-test-query-key)) +(def get-last-test-query (partial get* last-test-query-key)) + +(def set-last-failed-tests-query (partial set* last-failed-tests-key)) +(def get-last-failed-tests-query (partial get* last-failed-tests-key)) diff --git a/src/elin/handler/test.clj b/src/elin/handler/test.clj index 57086f85..555d14a2 100644 --- a/src/elin/handler/test.clj +++ b/src/elin/handler/test.clj @@ -31,7 +31,7 @@ (m/=> run-test-under-cursor [:=> [:cat e.s.handler/?Elin] any?]) (defn run-test-under-cursor - [{:as elin :component/keys [interceptor]}] + [{:as elin :component/keys [interceptor session-storage]}] (e/let [{:keys [code response options]} (e.f.evaluate/evaluate-current-top-list elin) {ns-str :ns} options var-name (or (some->> (extract-multi-method-name code) @@ -50,7 +50,7 @@ ;; cider-nrepl (let [query {:ns-query {:exactly [(:ns ctx)]} :exactly (:vars ctx)}] - (e.f.s.test/set-last-test-query elin query) + (e.f.s.test/set-last-test-query session-storage query) (assoc ctx :response (e.f.n.cider/test-var-query!! nrepl query))) ;; plain @@ -60,11 +60,11 @@ :vars vars' :current-file (:file ctx) :base-line (:line ctx)}] - (e.f.s.test/set-last-test-query elin query) + (e.f.s.test/set-last-test-query session-storage query) (assoc ctx :response (e.f.n.test/test-var-query!! nrepl query)))))))) (defn run-tests-in-ns - [{:as elin :component/keys [host interceptor]}] + [{:as elin :component/keys [host interceptor session-storage]}] (e/let [ns-str (e.f.sexpr/get-namespace elin) path (async/ (e.u.map/select-keys-by-namespace elin :component) @@ -82,7 +82,7 @@ (if (e.p.nrepl/supported-op? nrepl e.c.nrepl/test-var-query-op) ;; cider-nrepl (let [query {:ns-query {:exactly [(:ns ctx)]}}] - (e.f.s.test/set-last-test-query elin query) + (e.f.s.test/set-last-test-query session-storage query) (assoc ctx :response (e.f.n.cider/test-var-query!! nrepl query))) ;; plain (let [vars' `(vals (ns-interns '~(symbol (:ns ctx)))) @@ -90,12 +90,12 @@ :vars vars' :current-file (:file ctx) :base-line (:line ctx)}] - (e.f.s.test/set-last-test-query elin query) + (e.f.s.test/set-last-test-query session-storage query) (assoc ctx :response (e.f.n.test/test-var-query!! nrepl query)))))))) (defn rerun-last-tests - [{:as elin :component/keys [interceptor]}] - (let [query (e.f.s.test/get-last-test-query elin) + [{:as elin :component/keys [interceptor session-storage]}] + (let [query (e.f.s.test/get-last-test-query session-storage) context (-> (e.u.map/select-keys-by-namespace elin :component) (assoc :ns (or (:ns query) "") :line (or (:base-line query) 0)