mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 07:18:21 +02:00
♻️ Refactor configuration validation
Replace spec with schema
This commit is contained in:
parent
0a86d9d515
commit
9174bb140b
14 changed files with 267 additions and 344 deletions
|
@ -58,15 +58,14 @@
|
|||
(def ^:dynamic *system* nil)
|
||||
(def ^:dynamic *pool* nil)
|
||||
|
||||
(def defaults
|
||||
(def default
|
||||
{:database-uri "postgresql://postgres/penpot_test"
|
||||
:redis-uri "redis://redis/1"
|
||||
:file-change-snapshot-every 1})
|
||||
|
||||
(def config
|
||||
(->> (cf/read-env "penpot-test")
|
||||
(merge cf/defaults defaults)
|
||||
(us/conform ::cf/config)))
|
||||
(cf/read-config :prefix "penpot-test"
|
||||
:default (merge cf/default default)))
|
||||
|
||||
(def default-flags
|
||||
[:enable-secure-session-cookies
|
||||
|
@ -88,6 +87,8 @@
|
|||
app.auth/verify-password (fn [a b] {:valid (= a b)})
|
||||
app.common.features/get-enabled-features (fn [& _] app.common.features/supported-features)]
|
||||
|
||||
(cf/validate! :exit-on-error? false)
|
||||
|
||||
(fs/create-dir "/tmp/penpot")
|
||||
|
||||
(let [templates [{:id "test"
|
||||
|
@ -524,7 +525,6 @@
|
|||
([key default]
|
||||
(get data key (get cf/config key default)))))
|
||||
|
||||
|
||||
(defn reset-mock!
|
||||
[m]
|
||||
(swap! m (fn [m]
|
||||
|
|
|
@ -1127,9 +1127,9 @@
|
|||
(t/is (= 1 (:processed res))))
|
||||
|
||||
;; check that object thumbnails are still here
|
||||
(let [res (th/db-exec! ["select * from file_tagged_object_thumbnail"])]
|
||||
;; (th/print-result! res)
|
||||
(t/is (= 1 (count res))))
|
||||
(let [rows (th/db-query :file-tagged-object-thumbnail {:file-id (:id file)})]
|
||||
;; (app.common.pprint/pprint rows)
|
||||
(t/is (= 1 (count rows))))
|
||||
|
||||
;; insert object snapshot for for unknown frame
|
||||
(let [data {::th/type :create-file-object-thumbnail
|
||||
|
@ -1148,13 +1148,20 @@
|
|||
(th/db-exec! ["update file set has_media_trimmed=false where id=?" (:id file)])
|
||||
|
||||
;; check that we have all object thumbnails
|
||||
(let [res (th/db-exec! ["select * from file_tagged_object_thumbnail"])]
|
||||
(t/is (= 2 (count res))))
|
||||
(let [rows (th/db-query :file-tagged-object-thumbnail {:file-id (:id file)})]
|
||||
;; (app.common.pprint/pprint rows)
|
||||
(t/is (= 2 (count rows))))
|
||||
|
||||
;; run the task again
|
||||
(let [res (th/run-task! :file-gc {:min-age 0})]
|
||||
(t/is (= 1 (:processed res))))
|
||||
|
||||
;; check that we have all object thumbnails
|
||||
(let [rows (th/db-query :file-tagged-object-thumbnail {:file-id (:id file)})]
|
||||
;; (app.common.pprint/pprint rows)
|
||||
(t/is (= 2 (count rows))))
|
||||
|
||||
|
||||
;; check that the unknown frame thumbnail is deleted
|
||||
(let [rows (th/db-query :file-tagged-object-thumbnail {:file-id (:id file)})]
|
||||
(t/is (= 2 (count rows)))
|
||||
|
@ -1164,6 +1171,7 @@
|
|||
(t/is (= 3 (:processed res))))
|
||||
|
||||
(let [rows (th/db-query :file-tagged-object-thumbnail {:file-id (:id file)})]
|
||||
;; (app.common.pprint/pprint rows)
|
||||
(t/is (= 1 (count rows)))))))
|
||||
|
||||
(t/deftest file-thumbnail-ops
|
||||
|
@ -1220,7 +1228,3 @@
|
|||
|
||||
(let [rows (th/db-query :file-thumbnail {:file-id (:id file)})]
|
||||
(t/is (= 1 (count rows)))))))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue