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