mirror of
https://github.com/penpot/penpot.git
synced 2025-05-05 22:55:53 +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.uuid :as uuid]
|
||||
[uxbox.util.storage :as ust]
|
||||
[uxbox.config :as cfg]))
|
||||
[uxbox.config :as cfg]
|
||||
[vertx.util :as vu]))
|
||||
|
||||
(def ^:dynamic *context* nil)
|
||||
|
||||
(defn state-init
|
||||
[next]
|
||||
|
@ -33,7 +36,8 @@
|
|||
(mount/swap {#'uxbox.config/config config})
|
||||
(mount/start))
|
||||
(try
|
||||
(next)
|
||||
(binding [*context* (vu/get-or-create-context uxbox.core/system)]
|
||||
(next))
|
||||
(finally
|
||||
(mount/stop)))))
|
||||
|
||||
|
@ -120,13 +124,17 @@
|
|||
(catch Exception e#
|
||||
[(handle-error e#) nil])))
|
||||
|
||||
|
||||
(defmacro try-on!
|
||||
[expr]
|
||||
`(try
|
||||
(let [result# (deref ~expr)]
|
||||
{:error nil
|
||||
:result result#})
|
||||
(let [d# (p/deferred)]
|
||||
(->> #(p/finally ~expr (fn [v# e#]
|
||||
(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#
|
||||
{:error (handle-error e#)
|
||||
:result nil})))
|
||||
|
|
|
@ -96,8 +96,7 @@
|
|||
:width 800
|
||||
:height 800}
|
||||
|
||||
out (with-redefs [vc/*context* (vc/get-or-create-context system)]
|
||||
(th/try-on! (sm/handle data)))]
|
||||
out (th/try-on! (sm/handle data))]
|
||||
|
||||
;; (th/print-result! out)
|
||||
|
||||
|
@ -110,7 +109,8 @@
|
|||
(t/is (string? (get-in out [:result :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 :thumb-uri])))))
|
||||
(t/is (string? (get-in out [:result :thumb-uri])))
|
||||
))
|
||||
|
||||
(t/deftest mutation-import-image-file-from-collection
|
||||
(let [user @(th/create-user db/pool 1)
|
||||
|
|
Loading…
Add table
Reference in a new issue