mirror of
https://github.com/penpot/penpot.git
synced 2025-05-07 09:35:54 +02:00
✨ Enable context handling on tests.
This makes the test exection more similar to the real environment. Each test is executed in the eventloop thread pool.
This commit is contained in:
parent
da29f8db86
commit
f37c9a5adb
2 changed files with 17 additions and 9 deletions
|
@ -17,7 +17,10 @@
|
||||||
[uxbox.util.blob :as blob]
|
[uxbox.util.blob :as blob]
|
||||||
[uxbox.util.uuid :as uuid]
|
[uxbox.util.uuid :as uuid]
|
||||||
[uxbox.util.storage :as ust]
|
[uxbox.util.storage :as ust]
|
||||||
[uxbox.config :as cfg]))
|
[uxbox.config :as cfg]
|
||||||
|
[vertx.util :as vu]))
|
||||||
|
|
||||||
|
(def ^:dynamic *context* nil)
|
||||||
|
|
||||||
(defn state-init
|
(defn state-init
|
||||||
[next]
|
[next]
|
||||||
|
@ -33,7 +36,8 @@
|
||||||
(mount/swap {#'uxbox.config/config config})
|
(mount/swap {#'uxbox.config/config config})
|
||||||
(mount/start))
|
(mount/start))
|
||||||
(try
|
(try
|
||||||
(next)
|
(binding [*context* (vu/get-or-create-context uxbox.core/system)]
|
||||||
|
(next))
|
||||||
(finally
|
(finally
|
||||||
(mount/stop)))))
|
(mount/stop)))))
|
||||||
|
|
||||||
|
@ -120,13 +124,17 @@
|
||||||
(catch Exception e#
|
(catch Exception e#
|
||||||
[(handle-error e#) nil])))
|
[(handle-error e#) nil])))
|
||||||
|
|
||||||
|
|
||||||
(defmacro try-on!
|
(defmacro try-on!
|
||||||
[expr]
|
[expr]
|
||||||
`(try
|
`(try
|
||||||
(let [result# (deref ~expr)]
|
(let [d# (p/deferred)]
|
||||||
{:error nil
|
(->> #(p/finally ~expr (fn [v# e#]
|
||||||
:result result#})
|
(if e#
|
||||||
|
(p/reject! d# e#)
|
||||||
|
(p/resolve! d# v#))))
|
||||||
|
(vu/run-on-context! *context*))
|
||||||
|
(array-map :error nil
|
||||||
|
:result (deref d#)))
|
||||||
(catch Exception e#
|
(catch Exception e#
|
||||||
{:error (handle-error e#)
|
{:error (handle-error e#)
|
||||||
:result nil})))
|
:result nil})))
|
||||||
|
|
|
@ -96,8 +96,7 @@
|
||||||
:width 800
|
:width 800
|
||||||
:height 800}
|
:height 800}
|
||||||
|
|
||||||
out (with-redefs [vc/*context* (vc/get-or-create-context system)]
|
out (th/try-on! (sm/handle data))]
|
||||||
(th/try-on! (sm/handle data)))]
|
|
||||||
|
|
||||||
;; (th/print-result! out)
|
;; (th/print-result! out)
|
||||||
|
|
||||||
|
@ -110,7 +109,8 @@
|
||||||
(t/is (string? (get-in out [:result :path])))
|
(t/is (string? (get-in out [:result :path])))
|
||||||
(t/is (string? (get-in out [:result :thumb-path])))
|
(t/is (string? (get-in out [:result :thumb-path])))
|
||||||
(t/is (string? (get-in out [:result :uri])))
|
(t/is (string? (get-in out [:result :uri])))
|
||||||
(t/is (string? (get-in out [:result :thumb-uri])))))
|
(t/is (string? (get-in out [:result :thumb-uri])))
|
||||||
|
))
|
||||||
|
|
||||||
(t/deftest mutation-import-image-file-from-collection
|
(t/deftest mutation-import-image-file-from-collection
|
||||||
(let [user @(th/create-user db/pool 1)
|
(let [user @(th/create-user db/pool 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue