💄 Fix format issues on backend module

This commit is contained in:
Andrey Antukh 2023-11-29 12:53:34 +01:00
parent 99e323dabc
commit 87615ce221
58 changed files with 293 additions and 411 deletions

View file

@ -353,8 +353,7 @@
(get-name [props] (get-name [props]
(let [attr-kw (cf/get :oidc-name-attr "name") (let [attr-kw (cf/get :oidc-name-attr "name")
attr-ph (parse-attr-path provider attr-kw)] attr-ph (parse-attr-path provider attr-kw)]
(get-in props attr-ph))) (get-in props attr-ph)))]
]
(let [props (qualify-props provider info) (let [props (qualify-props provider info)
email (get-email props)] email (get-email props)]

View file

@ -97,7 +97,7 @@
:with-credentials (and (contains? cfg ::username) :with-credentials (and (contains? cfg ::username)
(contains? cfg ::password)) (contains? cfg ::password))
:min-size (::min-size cfg) :min-size (::min-size cfg)
:max-size (::max-size cfg)) :max-size (::max-size cfg))
(create-pool cfg))) (create-pool cfg)))
(defmethod ig/halt-key! ::pool (defmethod ig/halt-key! ::pool
@ -412,7 +412,7 @@
(.setSavepoint conn (name label)))) (.setSavepoint conn (name label))))
(defn release! (defn release!
[^Connection conn ^Savepoint sp ] [^Connection conn ^Savepoint sp]
(.releaseSavepoint conn sp)) (.releaseSavepoint conn sp))
(defn rollback! (defn rollback!

View file

@ -39,9 +39,9 @@
(let [{:keys [host port] :as url} (sto/get-object-url storage obj {:max-age signature-max-age})] (let [{:keys [host port] :as url} (sto/get-object-url storage obj {:max-age signature-max-age})]
{::rres/status 307 {::rres/status 307
::rres/headers {"location" (str url) ::rres/headers {"location" (str url)
"x-host" (cond-> host port (str ":" port)) "x-host" (cond-> host port (str ":" port))
"x-mtype" (-> obj meta :content-type) "x-mtype" (-> obj meta :content-type)
"cache-control" (str "max-age=" (inst-ms cache-max-age))}})) "cache-control" (str "max-age=" (inst-ms cache-max-age))}}))
(defn- serve-object-from-fs (defn- serve-object-from-fs
[{:keys [::path]} obj] [{:keys [::path]} obj]

View file

@ -230,8 +230,7 @@
(-> (io/resource "app/templates/error-report.v3.tmpl") (-> (io/resource "app/templates/error-report.v3.tmpl")
(tmpl/render (-> content (tmpl/render (-> content
(assoc :id id) (assoc :id id)
(assoc :created-at (dt/format-instant created-at :rfc1123)))))) (assoc :created-at (dt/format-instant created-at :rfc1123))))))]
]
(if-let [report (get-report request)] (if-let [report (get-report request)]
(let [result (case (:version report) (let [result (case (:version report)

View file

@ -117,21 +117,21 @@
:profile-id profile-id :profile-id profile-id
:session-id session-id}] :session-id session-id}]
;; Close profile subscription if exists ;; Close profile subscription if exists
(when-let [ch (:channel psub)] (when-let [ch (:channel psub)]
(sp/close! ch) (sp/close! ch)
(mbus/purge! msgbus [ch])) (mbus/purge! msgbus [ch]))
;; Close team subscription if exists ;; Close team subscription if exists
(when-let [ch (:channel tsub)] (when-let [ch (:channel tsub)]
(sp/close! ch) (sp/close! ch)
(mbus/purge! msgbus [ch])) (mbus/purge! msgbus [ch]))
;; Close file subscription if exists ;; Close file subscription if exists
(when-let [{:keys [topic channel]} fsub] (when-let [{:keys [topic channel]} fsub]
(sp/close! channel) (sp/close! channel)
(mbus/purge! msgbus [channel]) (mbus/purge! msgbus [channel])
(mbus/pub! msgbus :topic topic :message msg)))) (mbus/pub! msgbus :topic topic :message msg))))
(defmethod handle-message :subscribe-team (defmethod handle-message :subscribe-team
[{:keys [::mbus/msgbus]} {:keys [::ws/id ::ws/state ::ws/output-ch ::session-id]} {:keys [team-id] :as params}] [{:keys [::mbus/msgbus]} {:keys [::ws/id ::ws/state ::ws/output-ch ::session-id]} {:keys [team-id] :as params}]
@ -179,7 +179,7 @@
(let [message {:type :presence (let [message {:type :presence
:file-id file-id :file-id file-id
:session-id session-id :session-id session-id
:profile-id profile-id}] :profile-id profile-id}]
(mbus/pub! msgbus (mbus/pub! msgbus
:topic file-id :topic file-id
:message message))) :message message)))

View file

@ -182,5 +182,4 @@
"invalid-uri" "invalid-uri"
(instance? java.net.http.HttpConnectTimeoutException cause) (instance? java.net.http.HttpConnectTimeoutException cause)
"timeout" "timeout"))
))

View file

@ -160,8 +160,7 @@
{::mdef/name "penpot_executors_running_threads" {::mdef/name "penpot_executors_running_threads"
::mdef/help "Current number of threads with state RUNNING." ::mdef/help "Current number of threads with state RUNNING."
::mdef/labels ["name"] ::mdef/labels ["name"]
::mdef/type :gauge} ::mdef/type :gauge}})
})
(def system-config (def system-config
{::db/pool {::db/pool
@ -322,8 +321,7 @@
::setup/templates (ig/ref ::setup/templates) ::setup/templates (ig/ref ::setup/templates)
::props (ig/ref ::setup/props) ::props (ig/ref ::setup/props)
:pool (ig/ref ::db/pool) :pool (ig/ref ::db/pool)}
}
:app.rpc.doc/routes :app.rpc.doc/routes
{:methods (ig/ref :app.rpc/methods)} {:methods (ig/ref :app.rpc/methods)}
@ -443,8 +441,7 @@
::sto.s3/io-threads (cf/get :storage-assets-s3-io-threads)} ::sto.s3/io-threads (cf/get :storage-assets-s3-io-threads)}
[::assets :app.storage.fs/backend] [::assets :app.storage.fs/backend]
{::sto.fs/directory (cf/get :storage-assets-fs-directory)} {::sto.fs/directory (cf/get :storage-assets-fs-directory)}})
})
(def worker-config (def worker-config

View file

@ -94,7 +94,7 @@
writer (StringWriter.)] writer (StringWriter.)]
(TextFormat/write004 writer samples) (TextFormat/write004 writer samples)
{:headers {"content-type" TextFormat/CONTENT_TYPE_004} {:headers {"content-type" TextFormat/CONTENT_TYPE_004}
:body (.toString writer)})) :body (.toString writer)}))

View file

@ -337,9 +337,7 @@
:fn (mg/resource "app/migrations/sql/0106-mod-team-table.sql")} :fn (mg/resource "app/migrations/sql/0106-mod-team-table.sql")}
{:name "0107-mod-file-tagged-object-thumbnail-table" {:name "0107-mod-file-tagged-object-thumbnail-table"
:fn (mg/resource "app/migrations/sql/0107-mod-file-tagged-object-thumbnail-table.sql")} :fn (mg/resource "app/migrations/sql/0107-mod-file-tagged-object-thumbnail-table.sql")}])
])
(defn apply-migrations! (defn apply-migrations!
[pool name migrations] [pool name migrations]

View file

@ -181,8 +181,8 @@
(let [f (px/wrap-bindings f)] (let [f (px/wrap-bindings f)]
(p/await! (px/submit! executor f))))] (p/await! (px/submit! executor f))))]
(if (and cache id) (if (and cache id)
(invoke! cache metrics id nil f) (invoke! cache metrics id nil f)
(f))))) (f)))))
(def noop-fn (constantly nil)) (def noop-fn (constantly nil))

View file

@ -636,8 +636,8 @@
input (io/data-input-stream input)] input (io/data-input-stream input)]
(binding [*state* (volatile! {:media [] :index {}})] (binding [*state* (volatile! {:media [] :index {}})]
(let [team (teams/get-team options (let [team (teams/get-team options
:profile-id profile-id :profile-id profile-id
:project-id project-id) :project-id project-id)
validate? (contains? cf/flags :file-validation) validate? (contains? cf/flags :file-validation)
features (cfeat/get-team-enabled-features cf/flags team)] features (cfeat/get-team-enabled-features cf/flags team)]

View file

@ -361,7 +361,7 @@
{::doc/added "1.17" {::doc/added "1.17"
::sm/params schema:get-file-fragment ::sm/params schema:get-file-fragment
::sm/result schema:file-fragment} ::sm/result schema:file-fragment}
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id fragment-id share-id] }] [{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id fragment-id share-id]}]
(dm/with-open [conn (db/open pool)] (dm/with-open [conn (db/open pool)]
(let [perms (get-permissions conn profile-id file-id share-id)] (let [perms (get-permissions conn profile-id file-id share-id)]
(check-read-permissions! perms) (check-read-permissions! perms)
@ -491,7 +491,7 @@
page (dm/get-in file [:data :pages-index page-id])] page (dm/get-in file [:data :pages-index page-id])]
(if (pmap/pointer-map? page) (if (pmap/pointer-map? page)
(deref page) (deref page)
page)))] page)))]
(cond-> (prune-thumbnails page) (cond-> (prune-thumbnails page)
(some? object-id) (some? object-id)
@ -549,10 +549,10 @@
(defn get-team-shared-files (defn get-team-shared-files
[conn team-id] [conn team-id]
(letfn [(assets-sample [assets limit] (letfn [(assets-sample [assets limit]
(let [sorted-assets (->> (vals assets) (let [sorted-assets (->> (vals assets)
(sort-by #(str/lower (:name %))))] (sort-by #(str/lower (:name %))))]
{:count (count sorted-assets) {:count (count sorted-assets)
:sample (into [] (take limit sorted-assets))})) :sample (into [] (take limit sorted-assets))}))
(library-summary [{:keys [id data] :as file}] (library-summary [{:keys [id data] :as file}]
(binding [pmap/*load-fn* (partial load-pointer conn id)] (binding [pmap/*load-fn* (partial load-pointer conn id)]

View file

@ -78,8 +78,8 @@
(create-file-role! conn)) (create-file-role! conn))
(db/update! conn :project (db/update! conn :project
{:modified-at (dt/now)} {:modified-at (dt/now)}
{:id project-id}) {:id project-id})
(files/decode-row file))) (files/decode-row file)))

View file

@ -74,8 +74,8 @@
:file-id file-id) :file-id file-id)
(db/update! conn :file (db/update! conn :file
{:data (:data snapshot)} {:data (:data snapshot)}
{:id file-id}) {:id file-id})
;; clean object thumbnails ;; clean object thumbnails
(let [sql (str "delete from file_object_thumbnail " (let [sql (str "delete from file_object_thumbnail "

View file

@ -361,8 +361,7 @@
::sm/params [:map {:title "create-file-thumbnail"} ::sm/params [:map {:title "create-file-thumbnail"}
[:file-id ::sm/uuid] [:file-id ::sm/uuid]
[:revn :int] [:revn :int]
[:media ::media/upload]] [:media ::media/upload]]}
}
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id] :as params}] [{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id] :as params}]
(db/with-atomic [conn pool] (db/with-atomic [conn pool]

View file

@ -338,7 +338,7 @@
(cond-> (and (contains? cfeat/*current* "fdata/pointer-map") (cond-> (and (contains? cfeat/*current* "fdata/pointer-map")
(not (contains? cfeat/*previous* "fdata/pointer-map"))) (not (contains? cfeat/*previous* "fdata/pointer-map")))
(enable-pointer-map)) (enable-pointer-map))
(update :data blob/encode)))) (update :data blob/encode))))

View file

@ -81,8 +81,8 @@
perms (files/get-permissions conn profile-id file-id share-id)] perms (files/get-permissions conn profile-id file-id share-id)]
(files/check-read-permissions! perms) (files/check-read-permissions! perms)
(db/query conn :team-font-variant (db/query conn :team-font-variant
{:team-id (:team-id project) {:team-id (:team-id project)
:deleted-at nil}))))) :deleted-at nil})))))
(declare create-font-variant) (declare create-font-variant)
@ -157,8 +157,7 @@
:woff1-file-id (:id woff1) :woff1-file-id (:id woff1)
:woff2-file-id (:id woff2) :woff2-file-id (:id woff2)
:otf-file-id (:id otf) :otf-file-id (:id otf)
:ttf-file-id (:id ttf)})) :ttf-file-id (:id ttf)}))]
]
(let [data (-> (climit/configure cfg :process-font/global) (let [data (-> (climit/configure cfg :process-font/global)
(climit/run! (partial generate-missing! data) (climit/run! (partial generate-missing! data)

View file

@ -234,9 +234,9 @@
(assoc :is-pinned false)) (assoc :is-pinned false))
files (db/query conn :file files (db/query conn :file
{:project-id (:id project) {:project-id (:id project)
:deleted-at nil} :deleted-at nil}
{:columns [:id]}) {:columns [:id]})
project (cond-> project project (cond-> project
(string? name) (string? name)

View file

@ -106,8 +106,7 @@
profile (-> profile profile (-> profile
(assoc :fullname fullname) (assoc :fullname fullname)
(assoc :lang lang) (assoc :lang lang)
(assoc :theme theme)) (assoc :theme theme))]
]
(db/update! conn :profile (db/update! conn :profile
{:fullname fullname {:fullname fullname

View file

@ -50,11 +50,11 @@
is-owner (boolean (some :is-owner rows)) is-owner (boolean (some :is-owner rows))
is-admin (boolean (some :is-admin rows)) is-admin (boolean (some :is-admin rows))
can-edit (boolean (some :can-edit rows))] can-edit (boolean (some :can-edit rows))]
(when (seq rows) (when (seq rows)
{:is-owner is-owner {:is-owner is-owner
:is-admin (or is-owner is-admin) :is-admin (or is-owner is-admin)
:can-edit (or is-owner is-admin can-edit) :can-edit (or is-owner is-admin can-edit)
:can-read true}))) :can-read true})))
(def has-edit-permissions? (def has-edit-permissions?
(perms/make-edition-predicate-fn get-permissions)) (perms/make-edition-predicate-fn get-permissions))

View file

@ -56,11 +56,11 @@
is-owner (boolean (some :is-owner rows)) is-owner (boolean (some :is-owner rows))
is-admin (boolean (some :is-admin rows)) is-admin (boolean (some :is-admin rows))
can-edit (boolean (some :can-edit rows))] can-edit (boolean (some :can-edit rows))]
(when (seq rows) (when (seq rows)
{:is-owner is-owner {:is-owner is-owner
:is-admin (or is-owner is-admin) :is-admin (or is-owner is-admin)
:can-edit (or is-owner is-admin can-edit) :can-edit (or is-owner is-admin can-edit)
:can-read true}))) :can-read true})))
(def has-admin-permissions? (def has-admin-permissions?
(perms/make-admin-predicate-fn get-permissions)) (perms/make-admin-predicate-fn get-permissions))
@ -368,8 +368,8 @@
(let [conn (db/get-connection cfg-or-conn) (let [conn (db/get-connection cfg-or-conn)
team (create-team* conn params) team (create-team* conn params)
params (assoc params params (assoc params
:team-id (:id team) :team-id (:id team)
:role :owner) :role :owner)
project (create-team-default-project conn params)] project (create-team-default-project conn params)]
(create-team-role conn params) (create-team-role conn params)
(assoc team :default-project-id (:id project)))) (assoc team :default-project-id (:id project))))
@ -667,8 +667,8 @@
;; Save new photo ;; Save new photo
(db/update! pool :team (db/update! pool :team
{:photo-id (:id photo)} {:photo-id (:id photo)}
{:id team-id}) {:id team-id})
(assoc team :photo-id (:id photo))))) (assoc team :photo-id (:id photo)))))

View file

@ -88,7 +88,7 @@
context (assoc context :param-style pstyle)] context (assoc context :param-style pstyle)]
{::rres/status 200 {::rres/status 200
::rres/body (-> (io/resource "app/templates/api-doc.tmpl") ::rres/body (-> (io/resource "app/templates/api-doc.tmpl")
(tmpl/render context))})) (tmpl/render context))}))
(fn [_] (fn [_]
{::rres/status 404}))) {::rres/status 404})))
@ -141,8 +141,7 @@
{:name (-> mdata ::sv/name d/name) {:name (-> mdata ::sv/name d/name)
:module (-> (:ns mdata) (str/split ".") last) :module (-> (:ns mdata) (str/split ".") last)
:repr {:post rpost}})) :repr {:post rpost}}))]
]
(let [definitions (atom {}) (let [definitions (atom {})
options {:registry sr/default-registry options {:registry sr/default-registry
@ -158,16 +157,16 @@
(map (fn [doc] (map (fn [doc]
[(str/ffmt "/command/%" (:name doc)) (:repr doc)])) [(str/ffmt "/command/%" (:name doc)) (:repr doc)]))
(into {})))] (into {})))]
{:openapi "3.0.0" {:openapi "3.0.0"
:info {:version (:main cf/version)} :info {:version (:main cf/version)}
:servers [{:url (str/ffmt "%/api/rpc" (cf/get :public-uri)) :servers [{:url (str/ffmt "%/api/rpc" (cf/get :public-uri))
;; :description "penpot backend" ;; :description "penpot backend"
}] }]
:security :security
{:api_key []} {:api_key []}
:paths paths :paths paths
:components {:schemas @definitions}}))) :components {:schemas @definitions}})))
(defn openapi-json-handler (defn openapi-json-handler
[context] [context]
@ -192,7 +191,7 @@
{::rres/status 200 {::rres/status 200
::rres/headers {"content-type" "text/html"} ::rres/headers {"content-type" "text/html"}
::rres/body (-> (io/resource "app/templates/openapi.tmpl") ::rres/body (-> (io/resource "app/templates/openapi.tmpl")
(tmpl/render context))})) (tmpl/render context))}))
(fn [_] (fn [_]
{::rres/status 404}))) {::rres/status 404})))

View file

@ -158,15 +158,15 @@
(p/await! scope)) (p/await! scope))
(-> (deref feat/*stats*) (-> (deref feat/*stats*)
(assoc :elapsed (dt/format-duration (tpoint)))) (assoc :elapsed (dt/format-duration (tpoint))))
(catch Throwable cause (catch Throwable cause
(l/dbg :hint "migrate:error" :cause cause)) (l/dbg :hint "migrate:error" :cause cause))
(finally (finally
(let [elapsed (dt/format-duration (tpoint))] (let [elapsed (dt/format-duration (tpoint))]
(l/dbg :hint "migrate:end" :elapsed elapsed)))))))) (l/dbg :hint "migrate:end" :elapsed elapsed))))))))
(defn migrate-team! (defn migrate-team!
[{:keys [::db/pool] :as system} team-id [{:keys [::db/pool] :as system} team-id

View file

@ -96,9 +96,9 @@
:name (:name file))) :name (:name file)))
new-file)))) new-file))))
([file state] ([file state]
(rename-layout-attrs file) (rename-layout-attrs file)
(update state :total (fnil inc 0)))) (update state :total (fnil inc 0))))
(defn fix-components-shaperefs (defn fix-components-shaperefs
([file] ([file]
@ -369,11 +369,11 @@
(= (:shape-ref child) ref-child-id)) (= (:shape-ref child) ref-child-id))
false)) false))
equal? (every? matches? (d/zip-all (:shapes shape) (:shapes ref-shape)))] equal? (every? matches? (d/zip-all (:shapes shape) (:shapes ref-shape)))]
(when (and (not equal?) (not (cfh/touched-group? shape :shapes-group))) (when (and (not equal?) (not (cfh/touched-group? shape :shapes-group)))
(println " -> set touched " (:name shape) (:id shape) :shapes :shapes-group)) (println " -> set touched " (:name shape) (:id shape) :shapes :shapes-group))
(cond-> shape (cond-> shape
(and (not equal?) (not (cfh/touched-group? shape :shapes-group))) (and (not equal?) (not (cfh/touched-group? shape :shapes-group)))
(update :touched cfh/set-touched-group :shapes-group))))] (update :touched cfh/set-touched-group :shapes-group))))]
(as-> shape $ (as-> shape $
(reduce fix-touched-attr $ ctk/sync-attrs) (reduce fix-touched-attr $ ctk/sync-attrs)

View file

@ -245,8 +245,7 @@
(start-worker [input index] (start-worker [input index]
(px/thread (px/thread
{:name (str "penpot/srepl/worker/" index)} {:name (str "penpot/srepl/worker/" index)}
(run-worker input index))) (run-worker input index)))]
]
(when (fn? on-init) (on-init)) (when (fn? on-init) (on-init))

View file

@ -313,8 +313,7 @@
(= op :profile-id) (= op :profile-id)
(if (coll? param) (if (coll? param)
(sequence (keep parse-uuid) param) (sequence (keep parse-uuid) param)
(resolve-dest param)))))) (resolve-dest param))))))]
]
(->> (resolve-dest dest) (->> (resolve-dest dest)
(filter some?) (filter some?)

View file

@ -403,8 +403,7 @@
(do (do
(some->> (seq to-freeze) (mark-freeze-in-bulk conn)) (some->> (seq to-freeze) (mark-freeze-in-bulk conn))
(some->> (seq to-delete) (mark-delete-in-bulk conn)) (some->> (seq to-delete) (mark-delete-in-bulk conn))
[(count to-freeze) (count to-delete)])))) [(count to-freeze) (count to-delete)]))))]
]
(fn [_] (fn [_]
(db/with-atomic [conn pool] (db/with-atomic [conn pool]

View file

@ -18,8 +18,8 @@
[datoteka.io :as io] [datoteka.io :as io]
[integrant.core :as ig]) [integrant.core :as ig])
(:import (:import
java.nio.file.Path java.nio.file.Files
java.nio.file.Files)) java.nio.file.Path))
;; --- BACKEND INIT ;; --- BACKEND INIT

View file

@ -194,9 +194,7 @@
builder (cond-> ^S3AsyncClientBuilder builder builder (cond-> ^S3AsyncClientBuilder builder
(some? endpoint) (some? endpoint)
(.endpointOverride (URI. endpoint)))] (.endpointOverride (URI. endpoint)))]
(.build ^S3AsyncClientBuilder builder)) (.build ^S3AsyncClientBuilder builder))]
]
(reify (reify
clojure.lang.IDeref clojure.lang.IDeref
@ -265,15 +263,15 @@
(Optional/of (long (impl/get-size content)))) (Optional/of (long (impl/get-size content))))
(^void subscribe [_ ^Subscriber subscriber] (^void subscribe [_ ^Subscriber subscriber]
(let [sem (Semaphore. 0) (let [sem (Semaphore. 0)
thr (upload-thread id subscriber sem content)] thr (upload-thread id subscriber sem content)]
(.onSubscribe subscriber (.onSubscribe subscriber
(reify Subscription (reify Subscription
(cancel [_] (cancel [_]
(px/interrupt! thr) (px/interrupt! thr)
(.release sem 1)) (.release sem 1))
(request [_ n] (request [_ n]
(.release sem (int n))))))))) (.release sem (int n)))))))))
(defn- put-object (defn- put-object

View file

@ -151,7 +151,7 @@
{::db/return-keys? false}) {::db/return-keys? false})
count (db/get-update-count result)] count (db/get-update-count result)]
(when (pos? count) (when (pos? count)
(l/debug :hint "mark team for deletion" :id (str id) )) (l/debug :hint "mark team for deletion" :id (str id)))
(+ total count)))] (+ total count)))]

View file

@ -178,7 +178,7 @@
(defn- retrieve-enabled-auth-providers (defn- retrieve-enabled-auth-providers
[conn] [conn]
(let [sql (str "select auth_backend as backend, count(*) as total " (let [sql (str "select auth_backend as backend, count(*) as total "
" from profile group by 1") " from profile group by 1")
rows (db/exec! conn [sql])] rows (db/exec! conn [sql])]
(->> rows (->> rows
(map (fn [{:keys [backend total]}] (map (fn [{:keys [backend total]}]

View file

@ -8,8 +8,8 @@
"A syntactic helpers for using locks." "A syntactic helpers for using locks."
(:refer-clojure :exclude [locking]) (:refer-clojure :exclude [locking])
(:import (:import
java.util.concurrent.locks.ReentrantLock java.util.concurrent.locks.Lock
java.util.concurrent.locks.Lock)) java.util.concurrent.locks.ReentrantLock))
(defn create (defn create
[] []

View file

@ -335,8 +335,7 @@
Iterable Iterable
(iterator [this] (iterator [this]
(when-not loaded? (load! this)) (when-not loaded? (load! this))
(ObjectsMapIterator. (.iterator ^Iterable positions) this)) (ObjectsMapIterator. (.iterator ^Iterable positions) this)))
)
(defn create (defn create
([] ([]

View file

@ -371,8 +371,7 @@
::sm/decode instant ::sm/decode instant
:gen/gen (tgen/fmap (fn [i] (in-past i)) tgen/pos-int) :gen/gen (tgen/fmap (fn [i] (in-past i)) tgen/pos-int)
::oapi/type "string" ::oapi/type "string"
::oapi/format "iso" ::oapi/format "iso"}})
}})
(sm/def! ::duration (sm/def! ::duration
{:type :durations {:type :durations
@ -383,5 +382,4 @@
:title "duration" :title "duration"
::sm/decode duration ::sm/decode duration
::oapi/type "string" ::oapi/type "string"
::oapi/format "duration" ::oapi/format "duration"}})
}})

View file

@ -89,17 +89,17 @@
state (atom {}) state (atom {})
beats (atom #{}) beats (atom #{})
options (-> options options (-> options
(update ::handler wrap-handler) (update ::handler wrap-handler)
(assoc ::id id) (assoc ::id id)
(assoc ::state state) (assoc ::state state)
(assoc ::beats beats) (assoc ::beats beats)
(assoc ::created-at (dt/now)) (assoc ::created-at (dt/now))
(assoc ::input-ch input-ch) (assoc ::input-ch input-ch)
(assoc ::heartbeat-ch hbeat-ch) (assoc ::heartbeat-ch hbeat-ch)
(assoc ::output-ch output-ch) (assoc ::output-ch output-ch)
(assoc ::close-ch close-ch) (assoc ::close-ch close-ch)
(assoc ::remote-addr ip-addr) (assoc ::remote-addr ip-addr)
(assoc ::user-agent uagent))] (assoc ::user-agent uagent))]
{:on-open {:on-open
(fn on-open [channel] (fn on-open [channel]
@ -115,9 +115,9 @@
:on-close :on-close
(fn on-close [_channel code reason] (fn on-close [_channel code reason]
(l/info :fn "on-ws-terminate" (l/info :fn "on-ws-terminate"
:conn-id id :conn-id id
:code code :code code
:reason reason) :reason reason)
(sp/close! close-ch)) (sp/close! close-ch))
:on-error :on-error

View file

@ -25,9 +25,9 @@
[promesa.core :as p] [promesa.core :as p]
[promesa.exec :as px]) [promesa.exec :as px])
(:import (:import
java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.Executor java.util.concurrent.Executor
java.util.concurrent.Future)) java.util.concurrent.Future
java.util.concurrent.ThreadPoolExecutor))
(set! *warn-on-reflection* true) (set! *warn-on-reflection* true)

View file

@ -28,7 +28,7 @@
(defn bounce-report (defn bounce-report
[{:keys [token email] :or {email "user@example.com"}}] [{:keys [token email] :or {email "user@example.com"}}]
{"notificationType" "Bounce", {"notificationType" "Bounce",
"bounce" {"feedbackId""010701776d7dd251-c08d280d-9f47-41aa-b959-0094fec779d9-000000", "bounce" {"feedbackId" "010701776d7dd251-c08d280d-9f47-41aa-b959-0094fec779d9-000000",
"bounceType" "Permanent", "bounceType" "Permanent",
"bounceSubType" "General", "bounceSubType" "General",
"bouncedRecipients" [{"emailAddress" email, "bouncedRecipients" [{"emailAddress" email,
@ -113,8 +113,7 @@
(t/is (= "permanent" (:kind result))) (t/is (= "permanent" (:kind result)))
(t/is (= "general" (:category result))) (t/is (= "general" (:category result)))
(t/is (= ["user@example.com"] (mapv :email (:recipients result)))) (t/is (= ["user@example.com"] (mapv :email (:recipients result))))
(t/is (= (:id profile) (:profile-id result))) (t/is (= (:id profile) (:profile-id result)))))
))
(t/deftest test-parse-complaint-report (t/deftest test-parse-complaint-report
(let [profile (th/create-profile* 1) (let [profile (th/create-profile* 1)
@ -129,8 +128,7 @@
(t/is (= "abuse" (:kind result))) (t/is (= "abuse" (:kind result)))
(t/is (= nil (:category result))) (t/is (= nil (:category result)))
(t/is (= ["user@example.com"] (into [] (:recipients result)))) (t/is (= ["user@example.com"] (into [] (:recipients result))))
(t/is (= (:id profile) (:profile-id result))) (t/is (= (:id profile) (:profile-id result)))))
))
(t/deftest test-parse-complaint-report-without-token (t/deftest test-parse-complaint-report-without-token
(let [props (:app.setup/props th/*system*) (let [props (:app.setup/props th/*system*)
@ -141,8 +139,7 @@
(t/is (= "abuse" (:kind result))) (t/is (= "abuse" (:kind result)))
(t/is (= nil (:category result))) (t/is (= nil (:category result)))
(t/is (= ["user@example.com"] (into [] (:recipients result)))) (t/is (= ["user@example.com"] (into [] (:recipients result))))
(t/is (= nil (:profile-id result))) (t/is (= nil (:profile-id result)))))
))
(t/deftest test-process-bounce-report (t/deftest test-process-bounce-report
(let [profile (th/create-profile* 1) (let [profile (th/create-profile* 1)
@ -169,9 +166,7 @@
(t/is (= "user@example.com" (get-in rows [0 :email])))) (t/is (= "user@example.com" (get-in rows [0 :email]))))
(let [prof (db/get-by-id pool :profile (:id profile))] (let [prof (db/get-by-id pool :profile (:id profile))]
(t/is (false? (:is-muted prof)))) (t/is (false? (:is-muted prof))))))
))
(t/deftest test-process-complaint-report (t/deftest test-process-complaint-report
(let [profile (th/create-profile* 1) (let [profile (th/create-profile* 1)
@ -201,9 +196,7 @@
(let [prof (db/get-by-id pool :profile (:id profile))] (let [prof (db/get-by-id pool :profile (:id profile))]
(t/is (false? (:is-muted prof)))) (t/is (false? (:is-muted prof))))))
))
(t/deftest test-process-bounce-report-to-self (t/deftest test-process-bounce-report-to-self
(let [profile (th/create-profile* 1) (let [profile (th/create-profile* 1)

View file

@ -6,9 +6,9 @@
(ns backend-tests.email-sending-test (ns backend-tests.email-sending-test
(:require (:require
[backend-tests.helpers :as th]
[app.db :as db] [app.db :as db]
[app.email :as emails] [app.email :as emails]
[backend-tests.helpers :as th]
[clojure.test :as t] [clojure.test :as t]
[promesa.core :as p])) [promesa.core :as p]))

View file

@ -19,8 +19,8 @@
[app.config :as cf] [app.config :as cf]
[app.db :as db] [app.db :as db]
[app.main :as main] [app.main :as main]
[app.media :as-alias mtx]
[app.media] [app.media]
[app.media :as-alias mtx]
[app.migrations] [app.migrations]
[app.msgbus :as-alias mbus] [app.msgbus :as-alias mbus]
[app.rpc :as-alias rpc] [app.rpc :as-alias rpc]
@ -110,8 +110,7 @@
"alter table storage_object set unlogged;\n" "alter table storage_object set unlogged;\n"
"alter table server_error_report set unlogged;\n" "alter table server_error_report set unlogged;\n"
"alter table server_prop set unlogged;\n" "alter table server_prop set unlogged;\n"
"alter table global_complaint_report set unlogged;\n" "alter table global_complaint_report set unlogged;\n"])
])
(defn state-init (defn state-init
[next] [next]
@ -272,7 +271,7 @@
(defn create-file-media-object* (defn create-file-media-object*
([params] (create-file-media-object* *system* params)) ([params] (create-file-media-object* *system* params))
([system {:keys [name width height mtype file-id is-local media-id] ([system {:keys [name width height mtype file-id is-local media-id]
:or {name "sample" width 100 height 100 mtype "image/svg+xml" is-local true}}] :or {name "sample" width 100 height 100 mtype "image/svg+xml" is-local true}}]
(dm/with-open [conn (db/open system)] (dm/with-open [conn (db/open system)]
(db/insert! conn :file-media-object (db/insert! conn :file-media-object
@ -322,8 +321,8 @@
([system {:keys [project-id profile-id role] :or {role :owner}}] ([system {:keys [project-id profile-id role] :or {role :owner}}]
(dm/with-open [conn (db/open system)] (dm/with-open [conn (db/open system)]
(#'teams/create-project-role conn {:project-id project-id (#'teams/create-project-role conn {:project-id project-id
:profile-id profile-id :profile-id profile-id
:role role})))) :role role}))))
(defn create-file-role* (defn create-file-role*
([params] (create-file-role* *system* params)) ([params] (create-file-role* *system* params))
@ -336,7 +335,7 @@
(defn update-file* (defn update-file*
([params] (update-file* *system* params)) ([params] (update-file* *system* params))
([system {:keys [file-id changes session-id profile-id revn] ([system {:keys [file-id changes session-id profile-id revn]
:or {session-id (uuid/next) revn 0}}] :or {session-id (uuid/next) revn 0}}]
(db/tx-run! system (fn [{:keys [::db/conn] :as system}] (db/tx-run! system (fn [{:keys [::db/conn] :as system}]
(let [file (files.update/get-file conn file-id)] (let [file (files.update/get-file conn file-id)]
(files.update/update-file system (files.update/update-file system

View file

@ -65,9 +65,7 @@
;; Refresh webhook ;; Refresh webhook
(let [whk' (th/db-get :webhook {:id (:id whk)})] (let [whk' (th/db-get :webhook {:id (:id whk)})]
(t/is (nil? (:error-code whk')))) (t/is (nil? (:error-code whk')))))))
)))
(t/deftest run-webhook-handler-2 (t/deftest run-webhook-handler-2
(with-mocks [http-mock {:target 'app.http.client/req! :return {:status 400}}] (with-mocks [http-mock {:target 'app.http.client/req! :return {:status 400}}]
@ -114,6 +112,4 @@
(let [whk' (th/db-get :webhook {:id (:id whk)})] (let [whk' (th/db-get :webhook {:id (:id whk)})]
(t/is (= "unexpected-status:400" (:error-code whk'))) (t/is (= "unexpected-status:400" (:error-code whk')))
(t/is (= 3 (:error-count whk'))) (t/is (= 3 (:error-count whk')))
(t/is (false? (:is-active whk')))) (t/is (false? (:is-active whk')))))))
)))

View file

@ -9,8 +9,8 @@
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.db :as db] [app.db :as db]
[app.http :as http] [app.http :as http]
[app.storage :as sto]
[app.rpc :as-alias rpc] [app.rpc :as-alias rpc]
[app.storage :as sto]
[backend-tests.helpers :as th] [backend-tests.helpers :as th]
[clojure.test :as t] [clojure.test :as t]
[mockery.core :refer [with-mocks]])) [mockery.core :refer [with-mocks]]))

View file

@ -9,8 +9,8 @@
[app.common.pprint :as pp] [app.common.pprint :as pp]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.db :as db] [app.db :as db]
[app.util.time :as dt]
[app.rpc :as-alias rpc] [app.rpc :as-alias rpc]
[app.util.time :as dt]
[backend-tests.helpers :as th] [backend-tests.helpers :as th]
[clojure.test :as t])) [clojure.test :as t]))
@ -91,8 +91,6 @@
(t/is (= 1 (count rows))) (t/is (= 1 (count rows)))
(t/is (= (:id prof) (:profile-id row))) (t/is (= (:id prof) (:profile-id row)))
(t/is (= "navigate" (:name row))) (t/is (= "navigate" (:name row)))
(t/is (= "frontend" (:source row)))) (t/is (= "frontend" (:source row)))))))
)))

View file

@ -285,6 +285,4 @@
(t/is (th/success? out)) (t/is (th/success? out))
(let [threads (th/db-query :comment-thread {:file-id (:id file-1)})] (let [threads (th/db-query :comment-thread {:file-id (:id file-1)})]
(t/is (= 0 (count threads)))))) (t/is (= 0 (count threads)))))))))
)))

View file

@ -29,8 +29,7 @@
params {::th/type :get-file params {::th/type :get-file
:id (:id file1) :id (:id file1)
::rpc/profile-id (:id profile) ::rpc/profile-id (:id profile)
:features cfeat/supported-features :features cfeat/supported-features}]
}]
(binding [cond/*enabled* true] (binding [cond/*enabled* true]
(let [{:keys [error result] :as out} (th/command! params)] (let [{:keys [error result] :as out} (th/command! params)]
@ -46,6 +45,5 @@
{:keys [error result]} (th/command! (assoc params ::cond/key etag))] {:keys [error result]} (th/command! (assoc params ::cond/key etag))]
(t/is (nil? error)) (t/is (nil? error))
(t/is (fn? result)) (t/is (fn? result))
(t/is (= 304 (-> (result nil) :ring.response/status)))) (t/is (= 304 (-> (result nil) :ring.response/status))))))))
))))

View file

@ -124,8 +124,7 @@
(t/is (nil? (:error out))) (t/is (nil? (:error out)))
(let [result (:result out)] (let [result (:result out)]
(t/is (= 0 (count result)))))) (t/is (= 0 (count result))))))))
))
(t/deftest file-gc-with-fragments (t/deftest file-gc-with-fragments
(letfn [(update-file! [& {:keys [profile-id file-id changes revn] :or {revn 0}}] (letfn [(update-file! [& {:keys [profile-id file-id changes revn] :or {revn 0}}]
@ -226,9 +225,7 @@
;; Check the number of fragments; ;; Check the number of fragments;
(let [rows (th/db-query :file-data-fragment {:file-id (:id file)})] (let [rows (th/db-query :file-data-fragment {:file-id (:id file)})]
(t/is (= 2 (count rows)))) (t/is (= 2 (count rows)))))))
)))
(t/deftest file-gc-task-with-thumbnails (t/deftest file-gc-task-with-thumbnails
(letfn [(add-file-media-object [& {:keys [profile-id file-id]}] (letfn [(add-file-media-object [& {:keys [profile-id file-id]}]
@ -361,8 +358,7 @@
(t/is (nil? (sto/get-object storage (:media-id fmo2)))) (t/is (nil? (sto/get-object storage (:media-id fmo2))))
(t/is (nil? (sto/get-object storage (:thumbnail-id fmo2)))) (t/is (nil? (sto/get-object storage (:thumbnail-id fmo2))))
(t/is (nil? (sto/get-object storage (:media-id fmo1)))) (t/is (nil? (sto/get-object storage (:media-id fmo1))))
(t/is (nil? (sto/get-object storage (:thumbnail-id fmo1)))) (t/is (nil? (sto/get-object storage (:thumbnail-id fmo1)))))))
)))
(t/deftest file-gc-image-fills-and-strokes (t/deftest file-gc-image-fills-and-strokes
(letfn [(add-file-media-object [& {:keys [profile-id file-id]}] (letfn [(add-file-media-object [& {:keys [profile-id file-id]}]
@ -414,51 +410,51 @@
;; Update file inserting a new image object ;; Update file inserting a new image object
(update-file! (update-file!
:file-id (:id file) :file-id (:id file)
:profile-id (:id profile) :profile-id (:id profile)
:revn 0 :revn 0
:changes :changes
[{:type :add-obj [{:type :add-obj
:page-id page-id :page-id page-id
:id s-shid :id s-shid
:parent-id uuid/zero :parent-id uuid/zero
:frame-id uuid/zero :frame-id uuid/zero
:components-v2 true :components-v2 true
:obj (cts/setup-shape :obj (cts/setup-shape
{:id s-shid {:id s-shid
:name "image" :name "image"
:frame-id uuid/zero :frame-id uuid/zero
:parent-id uuid/zero :parent-id uuid/zero
:type :image :type :image
:metadata {:id (:id fmo1) :width 100 :height 100 :mtype "image/jpeg"} :metadata {:id (:id fmo1) :width 100 :height 100 :mtype "image/jpeg"}
:fills [{:opacity 1 :fill-image {:id (:id fmo2) :width 100 :height 100 :mtype "image/jpeg"}}] :fills [{:opacity 1 :fill-image {:id (:id fmo2) :width 100 :height 100 :mtype "image/jpeg"}}]
:strokes [{:opacity 1 :stroke-image {:id (:id fmo3) :width 100 :height 100 :mtype "image/jpeg"}}]})} :strokes [{:opacity 1 :stroke-image {:id (:id fmo3) :width 100 :height 100 :mtype "image/jpeg"}}]})}
{:type :add-obj {:type :add-obj
:page-id page-id :page-id page-id
:id t-shid :id t-shid
:parent-id uuid/zero :parent-id uuid/zero
:frame-id uuid/zero :frame-id uuid/zero
:components-v2 true :components-v2 true
:obj (cts/setup-shape :obj (cts/setup-shape
{:id t-shid {:id t-shid
:name "text" :name "text"
:frame-id uuid/zero :frame-id uuid/zero
:parent-id uuid/zero :parent-id uuid/zero
:type :text :type :text
:content {:type "root" :content {:type "root"
:children [{:type "paragraph-set" :children [{:type "paragraph-set"
:children [{:type "paragraph" :children [{:type "paragraph"
:children [{:fills [{:fill-opacity 1 :children [{:fills [{:fill-opacity 1
:fill-image {:id (:id fmo4) :fill-image {:id (:id fmo4)
:width 417 :width 417
:height 354 :height 354
:mtype "image/png" :mtype "image/png"
:name "text fill image"}}] :name "text fill image"}}]
:text "hi"} :text "hi"}
{:fills [{:fill-opacity 1 {:fills [{:fill-opacity 1
:fill-color "#000000"}] :fill-color "#000000"}]
:text "bye"}]}]}]} :text "bye"}]}]}]}
:strokes [{:opacity 1 :stroke-image {:id (:id fmo5) :width 100 :height 100 :mtype "image/jpeg"}}]})}]) :strokes [{:opacity 1 :stroke-image {:id (:id fmo5) :width 100 :height 100 :mtype "image/jpeg"}}]})}])
;; run the file-gc task immediately without forced min-age ;; run the file-gc task immediately without forced min-age
(let [res (th/run-task! "file-gc")] (let [res (th/run-task! "file-gc")]
@ -485,15 +481,15 @@
;; proceed to remove usage of the file ;; proceed to remove usage of the file
(update-file! (update-file!
:file-id (:id file) :file-id (:id file)
:profile-id (:id profile) :profile-id (:id profile)
:revn 0 :revn 0
:changes [{:type :del-obj :changes [{:type :del-obj
:page-id (first (get-in file [:data :pages])) :page-id (first (get-in file [:data :pages]))
:id s-shid} :id s-shid}
{:type :del-obj {:type :del-obj
:page-id (first (get-in file [:data :pages])) :page-id (first (get-in file [:data :pages]))
:id t-shid}]) :id t-shid}])
;; Now, we have deleted the usage of pointers to the ;; Now, we have deleted the usage of pointers to the
;; file-media-objects, if we paste file-gc, they should be marked ;; file-media-objects, if we paste file-gc, they should be marked
@ -572,8 +568,7 @@
fot-2 (insert-file-object-thumbnail! :profile-id (:id profile) fot-2 (insert-file-object-thumbnail! :profile-id (:id profile)
:page-id page-id :page-id page-id
:file-id file-id :file-id file-id
:frame-id frame-id-2) :frame-id frame-id-2)]
]
;; Add a two frames ;; Add a two frames
@ -700,9 +695,7 @@
;; check file media objects ;; check file media objects
(let [rows (th/db-exec! ["select * from storage_object where deleted_at is null"])] (let [rows (th/db-exec! ["select * from storage_object where deleted_at is null"])]
;; (pp/pprint rows) ;; (pp/pprint rows)
(t/is (= 0 (count rows)))) (t/is (= 0 (count rows)))))))
)))
@ -792,8 +785,8 @@
error (:error out)] error (:error out)]
;; (th/print-result! out) ;; (th/print-result! out)
(t/is (th/ex-info? error)) (t/is (th/ex-info? error))
(t/is (th/ex-of-type? error :not-found)))) (t/is (th/ex-of-type? error :not-found))))
(t/deftest permissions-checks-link-to-library-2 (t/deftest permissions-checks-link-to-library-2
(let [profile1 (th/create-profile* 1) (let [profile1 (th/create-profile* 1)
@ -814,8 +807,8 @@
error (:error out)] error (:error out)]
;; (th/print-result! out) ;; (th/print-result! out)
(t/is (th/ex-info? error)) (t/is (th/ex-info? error))
(t/is (th/ex-of-type? error :not-found)))) (t/is (th/ex-of-type? error :not-found))))
(t/deftest deletion (t/deftest deletion
(let [task (:app.tasks.objects-gc/handler th/*system*) (let [task (:app.tasks.objects-gc/handler th/*system*)
@ -881,8 +874,7 @@
(let [error (:error out) (let [error (:error out)
error-data (ex-data error)] error-data (ex-data error)]
(t/is (th/ex-info? error)) (t/is (th/ex-info? error))
(t/is (= (:type error-data) :not-found)))) (t/is (= (:type error-data) :not-found))))))
))
(t/deftest object-thumbnails-ops (t/deftest object-thumbnails-ops
@ -906,15 +898,15 @@
:use-for-thumbnail? true :use-for-thumbnail? true
:name "test-frame1" :name "test-frame1"
:type :frame})} :type :frame})}
{:type :add-obj {:type :add-obj
:page-id page-id :page-id page-id
:id shape1-id :id shape1-id
:parent-id frame1-id :parent-id frame1-id
:frame-id frame1-id :frame-id frame1-id
:obj (cts/setup-shape :obj (cts/setup-shape
{:id shape1-id {:id shape1-id
:name "test-shape1" :name "test-shape1"
:type :rect})} :type :rect})}
{:type :add-obj {:type :add-obj
:page-id page-id :page-id page-id
:id frame2-id :id frame2-id
@ -957,8 +949,7 @@
(t/is (contains? (:objects result) shape1-id)) (t/is (contains? (:objects result) shape1-id))
(t/is (contains? (:objects result) frame2-id)) (t/is (contains? (:objects result) frame2-id))
(t/is (contains? (:objects result) shape2-id)) (t/is (contains? (:objects result) shape2-id))
(t/is (contains? (:objects result) uuid/zero)) (t/is (contains? (:objects result) uuid/zero)))
)
;; Query :page RPC method with page-id ;; Query :page RPC method with page-id
(let [data {::th/type :get-page (let [data {::th/type :get-page
@ -1006,9 +997,7 @@
(t/is (not (th/success? out))) (t/is (not (th/success? out)))
(let [{:keys [type code]} (-> out :error ex-data)] (let [{:keys [type code]} (-> out :error ex-data)]
(t/is (= :validation type)) (t/is (= :validation type))
(t/is (= :params-validation code)))) (t/is (= :params-validation code)))))
)
(t/testing "RPC :file-data-for-thumbnail" (t/testing "RPC :file-data-for-thumbnail"
;; Insert a thumbnail data for the frame-id ;; Insert a thumbnail data for the frame-id
@ -1120,9 +1109,7 @@
;; check that the unknown frame thumbnail is deleted ;; check that the unknown frame thumbnail is deleted
(let [res (th/db-exec! ["select * from file_tagged_object_thumbnail"])] (let [res (th/db-exec! ["select * from file_tagged_object_thumbnail"])]
(t/is (= 1 (count res))))) (t/is (= 1 (count res)))))))
))
(t/deftest file-thumbnail-ops (t/deftest file-thumbnail-ops
@ -1163,9 +1150,7 @@
(t/is (map? result))) (t/is (map? result)))
(let [rows (th/db-query :file-thumbnail {:file-id (:id file)})] (let [rows (th/db-query :file-thumbnail {:file-id (:id file)})]
(t/is (= 2 (count rows)))) (t/is (= 2 (count rows)))))
)
(t/testing "gc task" (t/testing "gc task"
;; make the file eligible for GC waiting 300ms (configured ;; make the file eligible for GC waiting 300ms (configured
@ -1176,7 +1161,6 @@
(t/is (= 1 (:processed res)))) (t/is (= 1 (:processed res))))
(let [rows (th/db-query :file-thumbnail {:file-id (:id file)})] (let [rows (th/db-query :file-thumbnail {:file-id (:id file)})]
(t/is (= 1 (count rows))))) (t/is (= 1 (count rows)))))))
))

View file

@ -149,9 +149,7 @@
;; check that storage object is still exists but is marked as deleted ;; check that storage object is still exists but is marked as deleted
(let [row (th/db-get :storage-object {:id (:media-id row1)} {::db/remove-deleted? false})] (let [row (th/db-get :storage-object {:id (:media-id row1)} {::db/remove-deleted? false})]
(t/is (nil? row))) (t/is (nil? row))))))
)))
(t/deftest create-file-thumbnail (t/deftest create-file-thumbnail
(let [storage (::sto/storage th/*system*) (let [storage (::sto/storage th/*system*)
@ -241,10 +239,7 @@
(let [result (th/run-task! :storage-gc-deleted {:min-age (dt/duration 0)})] (let [result (th/run-task! :storage-gc-deleted {:min-age (dt/duration 0)})]
(t/is (= 1 (:deleted result)))) (t/is (= 1 (:deleted result))))
(t/is (some? (sto/get-object storage (:media-id row2))))) (t/is (some? (sto/get-object storage (:media-id row2)))))))
))
(t/deftest get-file-object-thumbnail (t/deftest get-file-object-thumbnail
(let [storage (::sto/storage th/*system*) (let [storage (::sto/storage th/*system*)
@ -254,21 +249,21 @@
:is-shared false}) :is-shared false})
data {::th/type :create-file-object-thumbnail data {::th/type :create-file-object-thumbnail
::rpc/profile-id (:id profile) ::rpc/profile-id (:id profile)
:file-id (:id file) :file-id (:id file)
:object-id "test-key-2" :object-id "test-key-2"
:media {:filename "sample.jpg" :media {:filename "sample.jpg"
:size 7923 :size 7923
:path (th/tempfile "backend_tests/test_files/sample2.jpg") :path (th/tempfile "backend_tests/test_files/sample2.jpg")
:mtype "image/jpeg"}}] :mtype "image/jpeg"}}]
(let [out (th/command! data)] (let [out (th/command! data)]
(t/is (nil? (:error out))) (t/is (nil? (:error out)))
(t/is (map? (:result out)))) (t/is (map? (:result out))))
(let [[row :as rows] (th/db-query :file-tagged-object-thumbnail (let [[row :as rows] (th/db-query :file-tagged-object-thumbnail
{:file-id (:id file)} {:file-id (:id file)}
{:order-by [[:created-at :asc]]})] {:order-by [[:created-at :asc]]})]
(t/is (= 1 (count rows))) (t/is (= 1 (count rows)))
(t/is (= (:file-id data) (:file-id row))) (t/is (= (:file-id data) (:file-id row)))

View file

@ -91,9 +91,7 @@
;; Check the total number of files ;; Check the total number of files
(let [rows (db/query th/*pool* :file {:project-id (:id project)})] (let [rows (db/query th/*pool* :file {:project-id (:id project)})]
(t/is (= 3 (count rows)))) (t/is (= 3 (count rows))))))))
))))
(t/deftest duplicate-file-with-deleted-relations (t/deftest duplicate-file-with-deleted-relations
(let [storage (-> (:app.storage/storage th/*system*) (let [storage (-> (:app.storage/storage th/*system*)
@ -149,9 +147,7 @@
;; Check the total number of files ;; Check the total number of files
(let [rows (db/query th/*pool* :file {:project-id (:id project)})] (let [rows (db/query th/*pool* :file {:project-id (:id project)})]
(t/is (= 3 (count rows)))) (t/is (= 3 (count rows))))))))
))))
(t/deftest duplicate-project (t/deftest duplicate-project
(let [storage (-> (:app.storage/storage th/*system*) (let [storage (-> (:app.storage/storage th/*system*)
@ -223,9 +219,7 @@
(when (= (:id fa) (:id file2)) (when (= (:id fa) (:id file2))
(t/is (false? (b/equals? (:data fa) (t/is (false? (b/equals? (:data fa)
(:data fb)))))) (:data fb)))))))))))
)))))
(t/deftest duplicate-project-with-deleted-files (t/deftest duplicate-project-with-deleted-files
(let [storage (-> (:app.storage/storage th/*system*) (let [storage (-> (:app.storage/storage th/*system*)
@ -289,9 +283,7 @@
(when (= (:id fa) (:id file2)) (when (= (:id fa) (:id file2))
(t/is (false? (b/equals? (:data fa) (t/is (false? (b/equals? (:data fa)
(:data fb)))))) (:data fb)))))))))))
)))))
(t/deftest move-file-on-same-team (t/deftest move-file-on-same-team
(let [profile (th/create-profile* 1 {:is-active true}) (let [profile (th/create-profile* 1 {:is-active true})
@ -359,8 +351,7 @@
;; should be no libraries on file2 ;; should be no libraries on file2
(let [rows (db/query th/*pool* :file-library-rel {:file-id (:id file2)})] (let [rows (db/query th/*pool* :file-library-rel {:file-id (:id file2)})]
(t/is (= 0 (count rows)))) (t/is (= 0 (count rows)))))))
)))
;; TODO: move a library to other team ;; TODO: move a library to other team
@ -445,8 +436,7 @@
(let [[item :as rows] (db/query th/*pool* :file-library-rel {:file-id (:id file2)})] (let [[item :as rows] (db/query th/*pool* :file-library-rel {:file-id (:id file2)})]
(t/is (= 1 (count rows))) (t/is (= 1 (count rows)))
(t/is (= (:file-id item) (:id file2))) (t/is (= (:file-id item) (:id file2)))
(t/is (= (:library-file-id item) (:id file3)))) (t/is (= (:library-file-id item) (:id file3)))))))
)))
(t/deftest move-library-to-other-team (t/deftest move-library-to-other-team
@ -515,9 +505,7 @@
;; the file2 should not have any link to libraries ;; the file2 should not have any link to libraries
(let [rows (db/query th/*pool* :file-library-rel {:file-id (:id file2)})] (let [rows (db/query th/*pool* :file-library-rel {:file-id (:id file2)})]
(t/is (zero? (count rows)))) (t/is (zero? (count rows)))))))
)))
(t/deftest move-project (t/deftest move-project
(let [profile (th/create-profile* 1 {:is-active true}) (let [profile (th/create-profile* 1 {:is-active true})
@ -602,9 +590,7 @@
{:order-by [:created-at]})] {:order-by [:created-at]})]
(t/is (= 1 (count rows))) (t/is (= 1 (count rows)))
(t/is (= (:file-id item1) (:id file1))) (t/is (= (:file-id item1) (:id file1)))
(t/is (= (:library-file-id item1) (:id file2)))) (t/is (= (:library-file-id item1) (:id file2)))))))
)))
(t/deftest clone-template (t/deftest clone-template
(let [prof (th/create-profile* 1 {:is-active true}) (let [prof (th/create-profile* 1 {:is-active true})

View file

@ -88,8 +88,7 @@
(t/is (sto/object? mobj1)) (t/is (sto/object? mobj1))
(t/is (sto/object? mobj2)) (t/is (sto/object? mobj2))
(t/is (= 312043 (:size mobj1))) (t/is (= 312043 (:size mobj1)))
(t/is (= 3887 (:size mobj2))))) (t/is (= 3887 (:size mobj2)))))))
))
(t/deftest media-object-upload-idempotency (t/deftest media-object-upload-idempotency
@ -208,8 +207,7 @@
(t/is (sto/object? mobj1)) (t/is (sto/object? mobj1))
(t/is (sto/object? mobj2)) (t/is (sto/object? mobj2))
(t/is (= 312043 (:size mobj1))) (t/is (= 312043 (:size mobj1)))
(t/is (= 3887 (:size mobj2))))) (t/is (= 3887 (:size mobj2)))))))
))
(t/deftest media-object-upload-idempotency-command (t/deftest media-object-upload-idempotency-command

View file

@ -6,11 +6,11 @@
(ns backend-tests.rpc-profile-test (ns backend-tests.rpc-profile-test
(:require (:require
[app.auth :as auth]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cf] [app.config :as cf]
[app.db :as db] [app.db :as db]
[app.rpc :as-alias rpc] [app.rpc :as-alias rpc]
[app.auth :as auth]
[app.tokens :as tokens] [app.tokens :as tokens]
[app.util.time :as dt] [app.util.time :as dt]
[backend-tests.helpers :as th] [backend-tests.helpers :as th]
@ -115,8 +115,7 @@
out (th/command! data)] out (th/command! data)]
;; (th/print-result! out) ;; (th/print-result! out)
(t/is (nil? (:error out))))) (t/is (nil? (:error out)))))))
))
(t/deftest profile-deletion-simple (t/deftest profile-deletion-simple
(let [prof (th/create-profile* 1) (let [prof (th/create-profile* 1)
@ -219,9 +218,7 @@
(let [rows (th/db-query :team-profile-rel {:team-id (:id team)})] (let [rows (th/db-query :team-profile-rel {:team-id (:id team)})]
(t/is (= 1 (count rows))) (t/is (= 1 (count rows)))
(t/is (= (:id prof2) (get-in rows [0 :profile-id]))) (t/is (= (:id prof2) (get-in rows [0 :profile-id])))
(t/is (= false (get-in rows [0 :is-owner])))) (t/is (= false (get-in rows [0 :is-owner]))))))
))
(t/deftest registration-domain-whitelist (t/deftest registration-domain-whitelist
(let [whitelist #{"gmail.com" "hey.com" "ya.ru"}] (let [whitelist #{"gmail.com" "hey.com" "ya.ru"}]
@ -258,8 +255,7 @@
:accept-terms-and-privacy true :accept-terms-and-privacy true
:accept-newsletter-subscription true}] :accept-newsletter-subscription true}]
(let [{:keys [result error]} (th/command! data)] (let [{:keys [result error]} (th/command! data)]
(t/is (nil? error)))) (t/is (nil? error))))))
))
(t/deftest prepare-register-and-register-profile-1 (t/deftest prepare-register-and-register-profile-1
(let [data {::th/type :prepare-register-profile (let [data {::th/type :prepare-register-profile
@ -288,8 +284,7 @@
:accept-newsletter-subscription true}] :accept-newsletter-subscription true}]
(let [{:keys [result error] :as out} (th/command! data)] (let [{:keys [result error] :as out} (th/command! data)]
;; (th/print-result! out) ;; (th/print-result! out)
(t/is (nil? error)))) (t/is (nil? error))))))
))
(t/deftest prepare-register-and-register-profile-2 (t/deftest prepare-register-and-register-profile-2
(with-redefs [app.rpc.commands.auth/register-retry-threshold (dt/duration 500)] (with-redefs [app.rpc.commands.auth/register-retry-threshold (dt/duration 500)]
@ -350,10 +345,7 @@
:accept-newsletter-subscription true} :accept-newsletter-subscription true}
out (th/command! data)] out (th/command! data)]
(t/is (th/success? out)) (t/is (th/success? out))
(t/is (= 1 (:call-count @mock)))) (t/is (= 1 (:call-count @mock))))))))
))
))
(t/deftest prepare-and-register-with-invitation-and-disabled-registration-1 (t/deftest prepare-and-register-with-invitation-and-disabled-registration-1
@ -405,8 +397,7 @@
(t/is (not (th/success? out))) (t/is (not (th/success? out)))
(let [edata (-> out :error ex-data)] (let [edata (-> out :error ex-data)]
(t/is (= :restriction (:type edata))) (t/is (= :restriction (:type edata)))
(t/is (= :email-does-not-match-invitation (:code edata)))) (t/is (= :email-does-not-match-invitation (:code edata)))))))
)))
(t/deftest prepare-register-with-registration-disabled (t/deftest prepare-register-with-registration-disabled
(with-redefs [app.config/flags #{}] (with-redefs [app.config/flags #{}]
@ -427,10 +418,10 @@
:password "foobar"} :password "foobar"}
out (th/command! data)] out (th/command! data)]
(t/is (not (th/success? out))) (t/is (not (th/success? out)))
(let [edata (-> out :error ex-data)] (let [edata (-> out :error ex-data)]
(t/is (= :validation (:type edata))) (t/is (= :validation (:type edata)))
(t/is (= :email-already-exists (:code edata)))))) (t/is (= :email-already-exists (:code edata))))))
(t/deftest register-profile-with-bounced-email (t/deftest register-profile-with-bounced-email
(let [pool (:app.db/pool th/*system*) (let [pool (:app.db/pool th/*system*)
@ -566,9 +557,7 @@
(t/is (= 2 (:call-count @mock))) (t/is (= 2 (:call-count @mock)))
(t/is (th/ex-info? error)) (t/is (th/ex-info? error))
(t/is (th/ex-of-type? error :validation)) (t/is (th/ex-of-type? error :validation))
(t/is (th/ex-of-code? error :email-has-permanent-bounces))) (t/is (th/ex-of-code? error :email-has-permanent-bounces))))))
)))
(t/deftest update-profile-password (t/deftest update-profile-password
@ -579,8 +568,7 @@
:password "foobarfoobar"} :password "foobarfoobar"}
out (th/command! data)] out (th/command! data)]
(t/is (nil? (:error out))) (t/is (nil? (:error out)))
(t/is (nil? (:result out))) (t/is (nil? (:result out)))))
))
(t/deftest update-profile-password-bad-old-password (t/deftest update-profile-password-bad-old-password

View file

@ -6,12 +6,12 @@
(ns backend-tests.rpc-project-test (ns backend-tests.rpc-project-test
(:require (:require
[backend-tests.helpers :as th]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.db :as db] [app.db :as db]
[app.rpc :as-alias rpc]
[app.http :as http] [app.http :as http]
[app.rpc :as-alias rpc]
[app.util.time :as dt] [app.util.time :as dt]
[backend-tests.helpers :as th]
[clojure.test :as t])) [clojure.test :as t]))
(t/use-fixtures :once th/state-init) (t/use-fixtures :once th/state-init)
@ -104,8 +104,7 @@
;; (th/print-result! out) ;; (th/print-result! out)
(t/is (nil? (:error out))) (t/is (nil? (:error out)))
(let [result (:result out)] (let [result (:result out)]
(t/is (= 1 (count result))))) (t/is (= 1 (count result)))))))
))
(t/deftest permissions-checks-create-project (t/deftest permissions-checks-create-project
(let [profile1 (th/create-profile* 1) (let [profile1 (th/create-profile* 1)
@ -237,5 +236,4 @@
(let [error (:error out) (let [error (:error out)
error-data (ex-data error)] error-data (ex-data error)]
(t/is (th/ex-info? error)) (t/is (th/ex-info? error))
(t/is (= (:type error-data) :not-found)))) (t/is (= (:type error-data) :not-found))))))
))

View file

@ -123,9 +123,7 @@
:quote 5}) :quote 5})
(check-ok! 4) (check-ok! 4)
(check-ko! 5) (check-ko! 5))))
)))
(t/deftest invitations-per-team-quote (t/deftest invitations-per-team-quote
(with-mocks [mock {:target 'app.config/get (with-mocks [mock {:target 'app.config/get
@ -268,7 +266,7 @@
:team-id (:default-team-id profile-2)}) :team-id (:default-team-id profile-2)})
data {::th/type :create-file data {::th/type :create-file
::rpc/profile-id (:id profile-1) ::rpc/profile-id (:id profile-1)
:project-id (:id project-1)} :project-id (:id project-1)}
check-ok! (fn [n] check-ok! (fn [n]
(let [data (assoc data :name (str "file" n)) (let [data (assoc data :name (str "file" n))
out (th/command! data)] out (th/command! data)]
@ -339,6 +337,4 @@
:quote 4}) :quote 4})
(check-ok! 4) (check-ok! 4)
(check-ko! 5) (check-ko! 5))))
)))

View file

@ -100,9 +100,7 @@
(let [edata (-> out :error ex-data)] (let [edata (-> out :error ex-data)]
(t/is (= :validation (:type edata))) (t/is (= :validation (:type edata)))
(t/is (= :member-is-muted (:code edata))))) (t/is (= :member-is-muted (:code edata))))))))
)))
(t/deftest invitation-tokens (t/deftest invitation-tokens
@ -159,9 +157,7 @@
(t/is (= :editor (:role claims))) (t/is (= :editor (:role claims)))
(t/is (= (:id team) (:team-id claims))) (t/is (= (:id team) (:team-id claims)))
(t/is (= (first (:emails data)) (:member-email claims))) (t/is (= (first (:emails data)) (:member-email claims)))
(t/is (= (:id profile2) (:member-id claims))))) (t/is (= (:id profile2) (:member-id claims))))))))
)))
(t/deftest accept-invitation-tokens (t/deftest accept-invitation-tokens
@ -243,9 +239,7 @@
(t/is (not (th/success? out))) (t/is (not (th/success? out)))
(let [edata (-> out :error ex-data)] (let [edata (-> out :error ex-data)]
(t/is (= :validation (:type edata))) (t/is (= :validation (:type edata)))
(t/is (= :invalid-token (:code edata)))))) (t/is (= :invalid-token (:code edata)))))))))
)))
(t/deftest create-team-invitations-with-email-verification-disabled (t/deftest create-team-invitations-with-email-verification-disabled
(with-mocks [mock {:target 'app.email/send! :return nil}] (with-mocks [mock {:target 'app.email/send! :return nil}]
@ -343,8 +337,7 @@
(t/is (not (th/success? out))) (t/is (not (th/success? out)))
(let [edata (-> out :error ex-data)] (let [edata (-> out :error ex-data)]
(t/is (= :not-found (:type edata))))) (t/is (= :not-found (:type edata)))))))
))
(t/deftest query-team-invitations (t/deftest query-team-invitations
(let [prof (th/create-profile* 1 {:is-active true}) (let [prof (th/create-profile* 1 {:is-active true})

View file

@ -6,10 +6,10 @@
(ns backend-tests.rpc-viewer-test (ns backend-tests.rpc-viewer-test
(:require (:require
[backend-tests.helpers :as th]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.db :as db] [app.db :as db]
[app.rpc :as-alias rpc] [app.rpc :as-alias rpc]
[backend-tests.helpers :as th]
[clojure.test :as t] [clojure.test :as t]
[datoteka.core :as fs])) [datoteka.core :as fs]))
@ -104,6 +104,4 @@
(t/is (nil? (:error out))) (t/is (nil? (:error out)))
(let [result (:result out)] (let [result (:result out)]
(t/is (contains? result :file)) (t/is (contains? result :file))
(t/is (contains? result :project))))) (t/is (contains? result :project)))))))
))

View file

@ -140,9 +140,7 @@
error-data (ex-data error)] error-data (ex-data error)]
(t/is (th/ex-info? error)) (t/is (th/ex-info? error))
(t/is (= (:type error-data) :not-found)) (t/is (= (:type error-data) :not-found))
(t/is (= (:code error-data) :object-not-found))))) (t/is (= (:code error-data) :object-not-found))))))))
)))
(t/deftest webhooks-quotes (t/deftest webhooks-quotes
(with-mocks [http-mock {:target 'app.http.client/req! (with-mocks [http-mock {:target 'app.http.client/req!

View file

@ -50,8 +50,7 @@
(t/is (= "data" (:other (meta object)))) (t/is (= "data" (:other (meta object))))
(t/is (= "text/plain" (:content-type (meta object)))) (t/is (= "text/plain" (:content-type (meta object))))
(t/is (= "content" (slurp (sto/get-object-data storage object)))) (t/is (= "content" (slurp (sto/get-object-data storage object))))
(t/is (= "content" (slurp (sto/get-object-path storage object)))) (t/is (= "content" (slurp (sto/get-object-path storage object))))))
))
(t/deftest put-and-retrieve-expired-object (t/deftest put-and-retrieve-expired-object
(let [storage (-> (:app.storage/storage th/*system*) (let [storage (-> (:app.storage/storage th/*system*)
@ -59,8 +58,7 @@
content (sto/content "content") content (sto/content "content")
object (sto/put-object! storage {::sto/content content object (sto/put-object! storage {::sto/content content
::sto/expired-at (dt/in-future {:seconds 1}) ::sto/expired-at (dt/in-future {:seconds 1})
:content-type "text/plain" :content-type "text/plain"})]
})]
(t/is (sto/object? object)) (t/is (sto/object? object))
(t/is (dt/instant? (:expired-at object))) (t/is (dt/instant? (:expired-at object)))
@ -71,8 +69,7 @@
(t/is (nil? (sto/get-object storage (:id object)))) (t/is (nil? (sto/get-object storage (:id object))))
(t/is (nil? (sto/get-object-data storage object))) (t/is (nil? (sto/get-object-data storage object)))
(t/is (nil? (sto/get-object-url storage object))) (t/is (nil? (sto/get-object-url storage object)))
(t/is (nil? (sto/get-object-path storage object))) (t/is (nil? (sto/get-object-path storage object)))))
))
(t/deftest put-and-delete-object (t/deftest put-and-delete-object
(let [storage (-> (:app.storage/storage th/*system*) (let [storage (-> (:app.storage/storage th/*system*)
@ -92,8 +89,7 @@
;; But you can't retrieve the object again because in database is ;; But you can't retrieve the object again because in database is
;; marked as deleted/expired. ;; marked as deleted/expired.
(t/is (nil? (sto/get-object storage (:id object)))) (t/is (nil? (sto/get-object storage (:id object))))))
))
(t/deftest test-deleted-gc-task (t/deftest test-deleted-gc-task
(let [storage (-> (:app.storage/storage th/*system*) (let [storage (-> (:app.storage/storage th/*system*)
@ -103,16 +99,13 @@
content3 (sto/content "content3") content3 (sto/content "content3")
object1 (sto/put-object! storage {::sto/content content1 object1 (sto/put-object! storage {::sto/content content1
::sto/expired-at (dt/now) ::sto/expired-at (dt/now)
:content-type "text/plain" :content-type "text/plain"})
})
object2 (sto/put-object! storage {::sto/content content2 object2 (sto/put-object! storage {::sto/content content2
::sto/expired-at (dt/in-past {:hours 2}) ::sto/expired-at (dt/in-past {:hours 2})
:content-type "text/plain" :content-type "text/plain"})
})
object3 (sto/put-object! storage {::sto/content content3 object3 (sto/put-object! storage {::sto/content content3
::sto/expired-at (dt/in-past {:hours 1}) ::sto/expired-at (dt/in-past {:hours 1})
:content-type "text/plain" :content-type "text/plain"})]
})]
(th/sleep 200) (th/sleep 200)
@ -186,8 +179,7 @@
;; now check that all objects are marked to be deleted ;; now check that all objects are marked to be deleted
(let [res (db/exec-one! th/*pool* ["select count(*) from storage_object where deleted_at is not null"])] (let [res (db/exec-one! th/*pool* ["select count(*) from storage_object where deleted_at is not null"])]
(t/is (= 0 (:count res)))) (t/is (= 0 (:count res)))))))
)))
(t/deftest test-touched-gc-task-2 (t/deftest test-touched-gc-task-2

View file

@ -6,9 +6,9 @@
(ns backend-tests.tasks-telemetry-test (ns backend-tests.tasks-telemetry-test
(:require (:require
[backend-tests.helpers :as th]
[app.db :as db] [app.db :as db]
[app.util.time :as dt] [app.util.time :as dt]
[backend-tests.helpers :as th]
[clojure.pprint :refer [pprint]] [clojure.pprint :refer [pprint]]
[clojure.test :as t] [clojure.test :as t]
[mockery.core :refer [with-mocks]])) [mockery.core :refer [with-mocks]]))

View file

@ -60,9 +60,7 @@
(t/testing "error on non-uuid keys" (t/testing "error on non-uuid keys"
(let [obj (omap/wrap {})] (let [obj (omap/wrap {})]
(t/is (thrown? IllegalArgumentException (assoc obj :foo "bar"))))) (t/is (thrown? IllegalArgumentException (assoc obj :foo "bar"))))))
)
(t/deftest internal-operation (t/deftest internal-operation
(t/testing "modified & compact" (t/testing "modified & compact"
@ -83,8 +81,7 @@
(t/is (= (get obj1 id1) (get obj2 id1))) (t/is (= (get obj1 id1) (get obj2 id1)))
(t/is (= (get obj1 id2) (get obj2 id2))) (t/is (= (get obj1 id2) (get obj2 id2)))
(t/is (= (count obj1) (count obj2))) (t/is (= (count obj1) (count obj2)))
(t/is (= (hash obj1) (hash obj2))))) (t/is (= (hash obj1) (hash obj2))))))
)
(t/deftest internal-encode-decode (t/deftest internal-encode-decode
(sg/check! (sg/check!
@ -95,11 +92,11 @@
obj3 (assoc obj2 uuid/zero 1) obj3 (assoc obj2 uuid/zero 1)
obj4 (omap/create (deref obj3))] obj4 (omap/create (deref obj3))]
;; (app.common.pprint/pprint data) ;; (app.common.pprint/pprint data)
(t/is (= (hash obj1) (hash obj2))) (t/is (= (hash obj1) (hash obj2)))
(t/is (not= (hash obj2) (hash obj3))) (t/is (not= (hash obj2) (hash obj3)))
(t/is (bytes? (deref obj3))) (t/is (bytes? (deref obj3)))
(t/is (pos? (alength (deref obj3)))) (t/is (pos? (alength (deref obj3))))
(t/is (= (hash obj3) (hash obj4))))))) (t/is (= (hash obj3) (hash obj4)))))))
(t/deftest fressian-encode-decode (t/deftest fressian-encode-decode
(sg/check! (sg/check!

View file

@ -55,8 +55,7 @@
(t/is (pmap/pointer-map? obj2)) (t/is (pmap/pointer-map? obj2))
(t/is (identical? tmp obj2)) (t/is (identical? tmp obj2))
(t/is (= 0 (count obj1))) (t/is (= 0 (count obj1)))
(t/is (= 0 (count obj2))))) (t/is (= 0 (count obj2))))))
)
(t/deftest internal-tracking (t/deftest internal-tracking
@ -118,7 +117,5 @@
(t/is (not (contains? obj1 :b))) (t/is (not (contains? obj1 :b)))
(t/is (= 1 (get obj1 :a))) (t/is (= 1 (get obj1 :a)))
(t/is (= nil (get obj1 :b))) (t/is (= nil (get obj1 :b)))
(t/is (= ::empty (get obj1 :b ::empty)))))) (t/is (= ::empty (get obj1 :b ::empty)))))))
)