mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
✨ Add strong file schema validation after file data migration
This commit is contained in:
@@ -75,7 +75,9 @@
|
||||
data
|
||||
(-> data
|
||||
(assoc :id id)
|
||||
(dissoc :version :libs))]
|
||||
(dissoc :version)
|
||||
(dissoc :libs)
|
||||
(ctf/check-file-data))]
|
||||
|
||||
(-> file
|
||||
(assoc :data data)
|
||||
|
||||
@@ -114,10 +114,10 @@
|
||||
(sm/register! ::typographies schema:typographies)
|
||||
|
||||
(def check-file
|
||||
(sm/check-fn schema:file :hint "check error on validating file"))
|
||||
(sm/check-fn schema:file :hint "invalid file"))
|
||||
|
||||
(def check-file-data
|
||||
(sm/check-fn schema:data))
|
||||
(sm/check-fn schema:data :hint "invalid file data"))
|
||||
|
||||
(def check-file-media
|
||||
(sm/check-fn schema:media))
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
[app.common.data :as d]
|
||||
[app.common.files.migrations :as cfm]
|
||||
[app.common.pprint :as pp]
|
||||
[app.common.types.file :as ctf]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(defmethod cfm/migrate-data "test/1" [data _] (update data :sum inc))
|
||||
@@ -17,7 +18,8 @@
|
||||
|
||||
(t/deftest generic-migration-subsystem-1
|
||||
(let [migrations (into (d/ordered-set) ["test/1" "test/2" "test/3"])]
|
||||
(with-redefs [cfm/available-migrations migrations]
|
||||
(with-redefs [cfm/available-migrations migrations
|
||||
ctf/check-file-data identity]
|
||||
(let [file {:data {:sum 1}
|
||||
:id 1
|
||||
:migrations (d/ordered-set "test/1")}
|
||||
|
||||
Reference in New Issue
Block a user