mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 08:20:45 -05:00
test(backend): improve tests fixtures
This commit is contained in:
parent
04a054474f
commit
af8d19ab60
7 changed files with 25 additions and 28 deletions
|
@ -40,23 +40,21 @@
|
|||
|
||||
(defn database-reset
|
||||
[next]
|
||||
(state-init
|
||||
(fn []
|
||||
(with-open [conn (db/connection)]
|
||||
(let [sql (str "SELECT table_name "
|
||||
" FROM information_schema.tables "
|
||||
" WHERE table_schema = 'public' "
|
||||
" AND table_name != 'migrations';")
|
||||
result (->> (sc/fetch conn sql)
|
||||
(map :table_name))]
|
||||
(sc/execute conn (str "TRUNCATE "
|
||||
(apply str (interpose ", " result))
|
||||
" CASCADE;"))))
|
||||
(try
|
||||
(next)
|
||||
(finally
|
||||
(st/clear! uxbox.media/media-storage)
|
||||
(st/clear! uxbox.media/assets-storage))))))
|
||||
(with-open [conn (db/connection)]
|
||||
(let [sql (str "SELECT table_name "
|
||||
" FROM information_schema.tables "
|
||||
" WHERE table_schema = 'public' "
|
||||
" AND table_name != 'migrations';")
|
||||
result (->> (sc/fetch conn sql)
|
||||
(map :table_name))]
|
||||
(sc/execute conn (str "TRUNCATE "
|
||||
(apply str (interpose ", " result))
|
||||
" CASCADE;"))))
|
||||
(try
|
||||
(next)
|
||||
(finally
|
||||
(st/clear! uxbox.media/media-storage)
|
||||
(st/clear! uxbox.media/assets-storage))))
|
||||
|
||||
(defmacro await
|
||||
[expr]
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
(defn -main
|
||||
[& args]
|
||||
(require 'uxbox.tests.test-projects)
|
||||
(require 'uxbox.tests.test-pages)
|
||||
(require 'uxbox.tests.test-images)
|
||||
(require 'uxbox.tests.test-icons)
|
||||
(require 'uxbox.tests.test-users)
|
||||
(let [{:keys [fail]} (test/run-all-tests #"^uxbox.tests.*")]
|
||||
(if (pos? fail)
|
||||
(System/exit fail)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[uxbox.services :as usv]
|
||||
[uxbox.tests.helpers :as th]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
(t/deftest test-http-list-icon-collections
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[uxbox.services :as usv]
|
||||
[uxbox.tests.helpers :as th]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
(t/deftest test-http-list-image-collections
|
||||
|
@ -166,6 +167,6 @@
|
|||
(th/with-server {:handler uapi/app}
|
||||
(let [uri (str th/+base-url+ "/api/library/images")
|
||||
[status data] (th/http-get user uri)]
|
||||
(println "RESPONSE:" status data)
|
||||
;; (println "RESPONSE:" status data)
|
||||
(t/is (= 200 status))
|
||||
(t/is (= 1 (count data))))))))
|
||||
|
|
|
@ -10,12 +10,9 @@
|
|||
[uxbox.services :as usv]
|
||||
[uxbox.tests.helpers :as th]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Frontend Test
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(t/deftest test-http-page-create
|
||||
(with-open [conn (db/connection)]
|
||||
(let [user (th/create-user conn 1)
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
[promesa.core :as p]
|
||||
[suricatta.core :as sc]
|
||||
[clj-uuid :as uuid]
|
||||
[catacumba.testing :refer (with-server)]
|
||||
[catacumba.serializers :as sz]
|
||||
[uxbox.db :as db]
|
||||
[uxbox.api :as uapi]
|
||||
[uxbox.services.projects :as uspr]
|
||||
|
@ -12,12 +10,9 @@
|
|||
[uxbox.services :as usv]
|
||||
[uxbox.tests.helpers :as th]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Frontend Test
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(t/deftest test-http-project-list
|
||||
(with-open [conn (db/connection)]
|
||||
(let [user (th/create-user conn 1)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
[uxbox.services :as usv]
|
||||
[uxbox.tests.helpers :as th]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
(t/deftest test-http-retrieve-profile
|
||||
|
|
Loading…
Reference in a new issue