mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 14:06:37 +02:00
💄 Fix format issues on backend module
This commit is contained in:
parent
99e323dabc
commit
87615ce221
58 changed files with 293 additions and 411 deletions
|
@ -353,8 +353,7 @@
|
|||
(get-name [props]
|
||||
(let [attr-kw (cf/get :oidc-name-attr "name")
|
||||
attr-ph (parse-attr-path provider attr-kw)]
|
||||
(get-in props attr-ph)))
|
||||
]
|
||||
(get-in props attr-ph)))]
|
||||
|
||||
(let [props (qualify-props provider info)
|
||||
email (get-email props)]
|
||||
|
|
|
@ -412,7 +412,7 @@
|
|||
(.setSavepoint conn (name label))))
|
||||
|
||||
(defn release!
|
||||
[^Connection conn ^Savepoint sp ]
|
||||
[^Connection conn ^Savepoint sp]
|
||||
(.releaseSavepoint conn sp))
|
||||
|
||||
(defn rollback!
|
||||
|
|
|
@ -230,8 +230,7 @@
|
|||
(-> (io/resource "app/templates/error-report.v3.tmpl")
|
||||
(tmpl/render (-> content
|
||||
(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)]
|
||||
(let [result (case (:version report)
|
||||
|
|
|
@ -182,5 +182,4 @@
|
|||
"invalid-uri"
|
||||
|
||||
(instance? java.net.http.HttpConnectTimeoutException cause)
|
||||
"timeout"
|
||||
))
|
||||
"timeout"))
|
||||
|
|
|
@ -160,8 +160,7 @@
|
|||
{::mdef/name "penpot_executors_running_threads"
|
||||
::mdef/help "Current number of threads with state RUNNING."
|
||||
::mdef/labels ["name"]
|
||||
::mdef/type :gauge}
|
||||
})
|
||||
::mdef/type :gauge}})
|
||||
|
||||
(def system-config
|
||||
{::db/pool
|
||||
|
@ -322,8 +321,7 @@
|
|||
::setup/templates (ig/ref ::setup/templates)
|
||||
::props (ig/ref ::setup/props)
|
||||
|
||||
:pool (ig/ref ::db/pool)
|
||||
}
|
||||
:pool (ig/ref ::db/pool)}
|
||||
|
||||
:app.rpc.doc/routes
|
||||
{:methods (ig/ref :app.rpc/methods)}
|
||||
|
@ -443,8 +441,7 @@
|
|||
::sto.s3/io-threads (cf/get :storage-assets-s3-io-threads)}
|
||||
|
||||
[::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
|
||||
|
|
|
@ -337,9 +337,7 @@
|
|||
:fn (mg/resource "app/migrations/sql/0106-mod-team-table.sql")}
|
||||
|
||||
{: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!
|
||||
[pool name migrations]
|
||||
|
|
|
@ -361,7 +361,7 @@
|
|||
{::doc/added "1.17"
|
||||
::sm/params schema:get-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)]
|
||||
(let [perms (get-permissions conn profile-id file-id share-id)]
|
||||
(check-read-permissions! perms)
|
||||
|
|
|
@ -361,8 +361,7 @@
|
|||
::sm/params [:map {:title "create-file-thumbnail"}
|
||||
[:file-id ::sm/uuid]
|
||||
[:revn :int]
|
||||
[:media ::media/upload]]
|
||||
}
|
||||
[:media ::media/upload]]}
|
||||
|
||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id] :as params}]
|
||||
(db/with-atomic [conn pool]
|
||||
|
|
|
@ -157,8 +157,7 @@
|
|||
:woff1-file-id (:id woff1)
|
||||
:woff2-file-id (:id woff2)
|
||||
:otf-file-id (:id otf)
|
||||
:ttf-file-id (:id ttf)}))
|
||||
]
|
||||
:ttf-file-id (:id ttf)}))]
|
||||
|
||||
(let [data (-> (climit/configure cfg :process-font/global)
|
||||
(climit/run! (partial generate-missing! data)
|
||||
|
|
|
@ -106,8 +106,7 @@
|
|||
profile (-> profile
|
||||
(assoc :fullname fullname)
|
||||
(assoc :lang lang)
|
||||
(assoc :theme theme))
|
||||
]
|
||||
(assoc :theme theme))]
|
||||
|
||||
(db/update! conn :profile
|
||||
{:fullname fullname
|
||||
|
|
|
@ -141,8 +141,7 @@
|
|||
|
||||
{:name (-> mdata ::sv/name d/name)
|
||||
:module (-> (:ns mdata) (str/split ".") last)
|
||||
:repr {:post rpost}}))
|
||||
]
|
||||
:repr {:post rpost}}))]
|
||||
|
||||
(let [definitions (atom {})
|
||||
options {:registry sr/default-registry
|
||||
|
|
|
@ -245,8 +245,7 @@
|
|||
(start-worker [input index]
|
||||
(px/thread
|
||||
{:name (str "penpot/srepl/worker/" index)}
|
||||
(run-worker input index)))
|
||||
]
|
||||
(run-worker input index)))]
|
||||
|
||||
(when (fn? on-init) (on-init))
|
||||
|
||||
|
|
|
@ -313,8 +313,7 @@
|
|||
(= op :profile-id)
|
||||
(if (coll? param)
|
||||
(sequence (keep parse-uuid) param)
|
||||
(resolve-dest param))))))
|
||||
]
|
||||
(resolve-dest param))))))]
|
||||
|
||||
(->> (resolve-dest dest)
|
||||
(filter some?)
|
||||
|
|
|
@ -403,8 +403,7 @@
|
|||
(do
|
||||
(some->> (seq to-freeze) (mark-freeze-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 [_]
|
||||
(db/with-atomic [conn pool]
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
[datoteka.io :as io]
|
||||
[integrant.core :as ig])
|
||||
(:import
|
||||
java.nio.file.Path
|
||||
java.nio.file.Files))
|
||||
java.nio.file.Files
|
||||
java.nio.file.Path))
|
||||
|
||||
;; --- BACKEND INIT
|
||||
|
||||
|
|
|
@ -194,9 +194,7 @@
|
|||
builder (cond-> ^S3AsyncClientBuilder builder
|
||||
(some? endpoint)
|
||||
(.endpointOverride (URI. endpoint)))]
|
||||
(.build ^S3AsyncClientBuilder builder))
|
||||
|
||||
]
|
||||
(.build ^S3AsyncClientBuilder builder))]
|
||||
|
||||
(reify
|
||||
clojure.lang.IDeref
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
{::db/return-keys? false})
|
||||
count (db/get-update-count result)]
|
||||
(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)))]
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
"A syntactic helpers for using locks."
|
||||
(:refer-clojure :exclude [locking])
|
||||
(:import
|
||||
java.util.concurrent.locks.ReentrantLock
|
||||
java.util.concurrent.locks.Lock))
|
||||
java.util.concurrent.locks.Lock
|
||||
java.util.concurrent.locks.ReentrantLock))
|
||||
|
||||
(defn create
|
||||
[]
|
||||
|
|
|
@ -335,8 +335,7 @@
|
|||
Iterable
|
||||
(iterator [this]
|
||||
(when-not loaded? (load! this))
|
||||
(ObjectsMapIterator. (.iterator ^Iterable positions) this))
|
||||
)
|
||||
(ObjectsMapIterator. (.iterator ^Iterable positions) this)))
|
||||
|
||||
(defn create
|
||||
([]
|
||||
|
|
|
@ -371,8 +371,7 @@
|
|||
::sm/decode instant
|
||||
:gen/gen (tgen/fmap (fn [i] (in-past i)) tgen/pos-int)
|
||||
::oapi/type "string"
|
||||
::oapi/format "iso"
|
||||
}})
|
||||
::oapi/format "iso"}})
|
||||
|
||||
(sm/def! ::duration
|
||||
{:type :durations
|
||||
|
@ -383,5 +382,4 @@
|
|||
:title "duration"
|
||||
::sm/decode duration
|
||||
::oapi/type "string"
|
||||
::oapi/format "duration"
|
||||
}})
|
||||
::oapi/format "duration"}})
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
[promesa.core :as p]
|
||||
[promesa.exec :as px])
|
||||
(:import
|
||||
java.util.concurrent.ThreadPoolExecutor
|
||||
java.util.concurrent.Executor
|
||||
java.util.concurrent.Future))
|
||||
java.util.concurrent.Future
|
||||
java.util.concurrent.ThreadPoolExecutor))
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
(defn bounce-report
|
||||
[{:keys [token email] :or {email "user@example.com"}}]
|
||||
{"notificationType" "Bounce",
|
||||
"bounce" {"feedbackId""010701776d7dd251-c08d280d-9f47-41aa-b959-0094fec779d9-000000",
|
||||
"bounce" {"feedbackId" "010701776d7dd251-c08d280d-9f47-41aa-b959-0094fec779d9-000000",
|
||||
"bounceType" "Permanent",
|
||||
"bounceSubType" "General",
|
||||
"bouncedRecipients" [{"emailAddress" email,
|
||||
|
@ -113,8 +113,7 @@
|
|||
(t/is (= "permanent" (:kind result)))
|
||||
(t/is (= "general" (:category 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
|
||||
(let [profile (th/create-profile* 1)
|
||||
|
@ -129,8 +128,7 @@
|
|||
(t/is (= "abuse" (:kind result)))
|
||||
(t/is (= nil (:category 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
|
||||
(let [props (:app.setup/props th/*system*)
|
||||
|
@ -141,8 +139,7 @@
|
|||
(t/is (= "abuse" (:kind result)))
|
||||
(t/is (= nil (:category 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
|
||||
(let [profile (th/create-profile* 1)
|
||||
|
@ -169,9 +166,7 @@
|
|||
(t/is (= "user@example.com" (get-in rows [0 :email]))))
|
||||
|
||||
(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
|
||||
(let [profile (th/create-profile* 1)
|
||||
|
@ -201,9 +196,7 @@
|
|||
|
||||
|
||||
(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
|
||||
(let [profile (th/create-profile* 1)
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
(ns backend-tests.email-sending-test
|
||||
(:require
|
||||
[backend-tests.helpers :as th]
|
||||
[app.db :as db]
|
||||
[app.email :as emails]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[promesa.core :as p]))
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.main :as main]
|
||||
[app.media :as-alias mtx]
|
||||
[app.media]
|
||||
[app.media :as-alias mtx]
|
||||
[app.migrations]
|
||||
[app.msgbus :as-alias mbus]
|
||||
[app.rpc :as-alias rpc]
|
||||
|
@ -110,8 +110,7 @@
|
|||
"alter table storage_object set unlogged;\n"
|
||||
"alter table server_error_report 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
|
||||
[next]
|
||||
|
|
|
@ -65,9 +65,7 @@
|
|||
|
||||
;; Refresh webhook
|
||||
(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
|
||||
(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)})]
|
||||
(t/is (= "unexpected-status:400" (:error-code whk')))
|
||||
(t/is (= 3 (:error-count whk')))
|
||||
(t/is (false? (:is-active whk'))))
|
||||
|
||||
)))
|
||||
(t/is (false? (:is-active whk')))))))
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
[app.common.uuid :as uuid]
|
||||
[app.db :as db]
|
||||
[app.http :as http]
|
||||
[app.storage :as sto]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.storage :as sto]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
[app.common.pprint :as pp]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.db :as db]
|
||||
[app.util.time :as dt]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.util.time :as dt]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]))
|
||||
|
||||
|
@ -91,8 +91,6 @@
|
|||
(t/is (= 1 (count rows)))
|
||||
(t/is (= (:id prof) (:profile-id row)))
|
||||
(t/is (= "navigate" (:name row)))
|
||||
(t/is (= "frontend" (:source row))))
|
||||
|
||||
)))
|
||||
(t/is (= "frontend" (:source row)))))))
|
||||
|
||||
|
||||
|
|
|
@ -285,6 +285,4 @@
|
|||
(t/is (th/success? out))
|
||||
|
||||
(let [threads (th/db-query :comment-thread {:file-id (:id file-1)})]
|
||||
(t/is (= 0 (count threads))))))
|
||||
|
||||
)))
|
||||
(t/is (= 0 (count threads)))))))))
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
params {::th/type :get-file
|
||||
:id (:id file1)
|
||||
::rpc/profile-id (:id profile)
|
||||
:features cfeat/supported-features
|
||||
}]
|
||||
:features cfeat/supported-features}]
|
||||
|
||||
(binding [cond/*enabled* true]
|
||||
(let [{:keys [error result] :as out} (th/command! params)]
|
||||
|
@ -46,6 +45,5 @@
|
|||
{:keys [error result]} (th/command! (assoc params ::cond/key etag))]
|
||||
(t/is (nil? error))
|
||||
(t/is (fn? result))
|
||||
(t/is (= 304 (-> (result nil) :ring.response/status))))
|
||||
))))
|
||||
(t/is (= 304 (-> (result nil) :ring.response/status))))))))
|
||||
|
||||
|
|
|
@ -124,8 +124,7 @@
|
|||
(t/is (nil? (:error out)))
|
||||
|
||||
(let [result (:result out)]
|
||||
(t/is (= 0 (count result))))))
|
||||
))
|
||||
(t/is (= 0 (count result))))))))
|
||||
|
||||
(t/deftest file-gc-with-fragments
|
||||
(letfn [(update-file! [& {:keys [profile-id file-id changes revn] :or {revn 0}}]
|
||||
|
@ -226,9 +225,7 @@
|
|||
|
||||
;; Check the number of fragments;
|
||||
(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
|
||||
(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 (:thumbnail-id fmo2))))
|
||||
(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
|
||||
(letfn [(add-file-media-object [& {:keys [profile-id file-id]}]
|
||||
|
@ -572,8 +568,7 @@
|
|||
fot-2 (insert-file-object-thumbnail! :profile-id (:id profile)
|
||||
:page-id page-id
|
||||
:file-id file-id
|
||||
:frame-id frame-id-2)
|
||||
]
|
||||
:frame-id frame-id-2)]
|
||||
|
||||
;; Add a two frames
|
||||
|
||||
|
@ -700,9 +695,7 @@
|
|||
;; check file media objects
|
||||
(let [rows (th/db-exec! ["select * from storage_object where deleted_at is null"])]
|
||||
;; (pp/pprint rows)
|
||||
(t/is (= 0 (count rows))))
|
||||
|
||||
)))
|
||||
(t/is (= 0 (count rows)))))))
|
||||
|
||||
|
||||
|
||||
|
@ -881,8 +874,7 @@
|
|||
(let [error (:error out)
|
||||
error-data (ex-data 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
|
||||
|
@ -957,8 +949,7 @@
|
|||
(t/is (contains? (:objects result) shape1-id))
|
||||
(t/is (contains? (:objects result) frame2-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
|
||||
(let [data {::th/type :get-page
|
||||
|
@ -1006,9 +997,7 @@
|
|||
(t/is (not (th/success? out)))
|
||||
(let [{:keys [type code]} (-> out :error ex-data)]
|
||||
(t/is (= :validation type))
|
||||
(t/is (= :params-validation code))))
|
||||
|
||||
)
|
||||
(t/is (= :params-validation code)))))
|
||||
|
||||
(t/testing "RPC :file-data-for-thumbnail"
|
||||
;; Insert a thumbnail data for the frame-id
|
||||
|
@ -1120,9 +1109,7 @@
|
|||
|
||||
;; check that the unknown frame thumbnail is deleted
|
||||
(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
|
||||
|
@ -1163,9 +1150,7 @@
|
|||
(t/is (map? result)))
|
||||
|
||||
(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"
|
||||
;; make the file eligible for GC waiting 300ms (configured
|
||||
|
@ -1176,7 +1161,6 @@
|
|||
(t/is (= 1 (:processed res))))
|
||||
|
||||
(let [rows (th/db-query :file-thumbnail {:file-id (:id file)})]
|
||||
(t/is (= 1 (count rows)))))
|
||||
))
|
||||
(t/is (= 1 (count rows)))))))
|
||||
|
||||
|
||||
|
|
|
@ -149,9 +149,7 @@
|
|||
|
||||
;; 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})]
|
||||
(t/is (nil? row)))
|
||||
|
||||
)))
|
||||
(t/is (nil? row))))))
|
||||
|
||||
(t/deftest create-file-thumbnail
|
||||
(let [storage (::sto/storage th/*system*)
|
||||
|
@ -241,10 +239,7 @@
|
|||
(let [result (th/run-task! :storage-gc-deleted {:min-age (dt/duration 0)})]
|
||||
(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
|
||||
(let [storage (::sto/storage th/*system*)
|
||||
|
|
|
@ -91,9 +91,7 @@
|
|||
|
||||
;; Check the total number of files
|
||||
(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
|
||||
(let [storage (-> (:app.storage/storage th/*system*)
|
||||
|
@ -149,9 +147,7 @@
|
|||
|
||||
;; Check the total number of files
|
||||
(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
|
||||
(let [storage (-> (:app.storage/storage th/*system*)
|
||||
|
@ -223,9 +219,7 @@
|
|||
|
||||
(when (= (:id fa) (:id file2))
|
||||
(t/is (false? (b/equals? (:data fa)
|
||||
(:data fb))))))
|
||||
|
||||
)))))
|
||||
(:data fb)))))))))))
|
||||
|
||||
(t/deftest duplicate-project-with-deleted-files
|
||||
(let [storage (-> (:app.storage/storage th/*system*)
|
||||
|
@ -289,9 +283,7 @@
|
|||
|
||||
(when (= (:id fa) (:id file2))
|
||||
(t/is (false? (b/equals? (:data fa)
|
||||
(:data fb))))))
|
||||
|
||||
)))))
|
||||
(:data fb)))))))))))
|
||||
|
||||
(t/deftest move-file-on-same-team
|
||||
(let [profile (th/create-profile* 1 {:is-active true})
|
||||
|
@ -359,8 +351,7 @@
|
|||
|
||||
;; should be no libraries on 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
|
||||
|
@ -445,8 +436,7 @@
|
|||
(let [[item :as rows] (db/query th/*pool* :file-library-rel {:file-id (:id file2)})]
|
||||
(t/is (= 1 (count rows)))
|
||||
(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
|
||||
|
@ -515,9 +505,7 @@
|
|||
|
||||
;; the file2 should not have any link to libraries
|
||||
(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
|
||||
(let [profile (th/create-profile* 1 {:is-active true})
|
||||
|
@ -602,9 +590,7 @@
|
|||
{:order-by [:created-at]})]
|
||||
(t/is (= 1 (count rows)))
|
||||
(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
|
||||
(let [prof (th/create-profile* 1 {:is-active true})
|
||||
|
|
|
@ -88,8 +88,7 @@
|
|||
(t/is (sto/object? mobj1))
|
||||
(t/is (sto/object? mobj2))
|
||||
(t/is (= 312043 (:size mobj1)))
|
||||
(t/is (= 3887 (:size mobj2)))))
|
||||
))
|
||||
(t/is (= 3887 (:size mobj2)))))))
|
||||
|
||||
|
||||
(t/deftest media-object-upload-idempotency
|
||||
|
@ -208,8 +207,7 @@
|
|||
(t/is (sto/object? mobj1))
|
||||
(t/is (sto/object? mobj2))
|
||||
(t/is (= 312043 (:size mobj1)))
|
||||
(t/is (= 3887 (:size mobj2)))))
|
||||
))
|
||||
(t/is (= 3887 (:size mobj2)))))))
|
||||
|
||||
|
||||
(t/deftest media-object-upload-idempotency-command
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
(ns backend-tests.rpc-profile-test
|
||||
(:require
|
||||
[app.auth :as auth]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.auth :as auth]
|
||||
[app.tokens :as tokens]
|
||||
[app.util.time :as dt]
|
||||
[backend-tests.helpers :as th]
|
||||
|
@ -115,8 +115,7 @@
|
|||
out (th/command! data)]
|
||||
|
||||
;; (th/print-result! out)
|
||||
(t/is (nil? (:error out)))))
|
||||
))
|
||||
(t/is (nil? (:error out)))))))
|
||||
|
||||
(t/deftest profile-deletion-simple
|
||||
(let [prof (th/create-profile* 1)
|
||||
|
@ -219,9 +218,7 @@
|
|||
(let [rows (th/db-query :team-profile-rel {:team-id (:id team)})]
|
||||
(t/is (= 1 (count rows)))
|
||||
(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
|
||||
(let [whitelist #{"gmail.com" "hey.com" "ya.ru"}]
|
||||
|
@ -258,8 +255,7 @@
|
|||
:accept-terms-and-privacy true
|
||||
:accept-newsletter-subscription true}]
|
||||
(let [{:keys [result error]} (th/command! data)]
|
||||
(t/is (nil? error))))
|
||||
))
|
||||
(t/is (nil? error))))))
|
||||
|
||||
(t/deftest prepare-register-and-register-profile-1
|
||||
(let [data {::th/type :prepare-register-profile
|
||||
|
@ -288,8 +284,7 @@
|
|||
:accept-newsletter-subscription true}]
|
||||
(let [{:keys [result error] :as out} (th/command! data)]
|
||||
;; (th/print-result! out)
|
||||
(t/is (nil? error))))
|
||||
))
|
||||
(t/is (nil? error))))))
|
||||
|
||||
(t/deftest prepare-register-and-register-profile-2
|
||||
(with-redefs [app.rpc.commands.auth/register-retry-threshold (dt/duration 500)]
|
||||
|
@ -350,10 +345,7 @@
|
|||
:accept-newsletter-subscription true}
|
||||
out (th/command! data)]
|
||||
(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
|
||||
|
@ -405,8 +397,7 @@
|
|||
(t/is (not (th/success? out)))
|
||||
(let [edata (-> out :error ex-data)]
|
||||
(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
|
||||
(with-redefs [app.config/flags #{}]
|
||||
|
@ -566,9 +557,7 @@
|
|||
(t/is (= 2 (:call-count @mock)))
|
||||
(t/is (th/ex-info? error))
|
||||
(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
|
||||
|
@ -579,8 +568,7 @@
|
|||
:password "foobarfoobar"}
|
||||
out (th/command! data)]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (nil? (:result out)))
|
||||
))
|
||||
(t/is (nil? (:result out)))))
|
||||
|
||||
|
||||
(t/deftest update-profile-password-bad-old-password
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
(ns backend-tests.rpc-project-test
|
||||
(:require
|
||||
[backend-tests.helpers :as th]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.db :as db]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.http :as http]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.util.time :as dt]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
|
@ -104,8 +104,7 @@
|
|||
;; (th/print-result! out)
|
||||
(t/is (nil? (:error out)))
|
||||
(let [result (:result out)]
|
||||
(t/is (= 1 (count result)))))
|
||||
))
|
||||
(t/is (= 1 (count result)))))))
|
||||
|
||||
(t/deftest permissions-checks-create-project
|
||||
(let [profile1 (th/create-profile* 1)
|
||||
|
@ -237,5 +236,4 @@
|
|||
(let [error (:error out)
|
||||
error-data (ex-data error)]
|
||||
(t/is (th/ex-info? error))
|
||||
(t/is (= (:type error-data) :not-found))))
|
||||
))
|
||||
(t/is (= (:type error-data) :not-found))))))
|
||||
|
|
|
@ -123,9 +123,7 @@
|
|||
:quote 5})
|
||||
|
||||
(check-ok! 4)
|
||||
(check-ko! 5)
|
||||
|
||||
)))
|
||||
(check-ko! 5))))
|
||||
|
||||
(t/deftest invitations-per-team-quote
|
||||
(with-mocks [mock {:target 'app.config/get
|
||||
|
@ -339,6 +337,4 @@
|
|||
:quote 4})
|
||||
|
||||
(check-ok! 4)
|
||||
(check-ko! 5)
|
||||
|
||||
)))
|
||||
(check-ko! 5))))
|
||||
|
|
|
@ -100,9 +100,7 @@
|
|||
|
||||
(let [edata (-> out :error ex-data)]
|
||||
(t/is (= :validation (:type edata)))
|
||||
(t/is (= :member-is-muted (:code edata)))))
|
||||
|
||||
)))
|
||||
(t/is (= :member-is-muted (:code edata))))))))
|
||||
|
||||
|
||||
(t/deftest invitation-tokens
|
||||
|
@ -159,9 +157,7 @@
|
|||
(t/is (= :editor (:role claims)))
|
||||
(t/is (= (:id team) (:team-id 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
|
||||
|
@ -243,9 +239,7 @@
|
|||
(t/is (not (th/success? out)))
|
||||
(let [edata (-> out :error ex-data)]
|
||||
(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
|
||||
(with-mocks [mock {:target 'app.email/send! :return nil}]
|
||||
|
@ -343,8 +337,7 @@
|
|||
|
||||
(t/is (not (th/success? out)))
|
||||
(let [edata (-> out :error ex-data)]
|
||||
(t/is (= :not-found (:type edata)))))
|
||||
))
|
||||
(t/is (= :not-found (:type edata)))))))
|
||||
|
||||
(t/deftest query-team-invitations
|
||||
(let [prof (th/create-profile* 1 {:is-active true})
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
(ns backend-tests.rpc-viewer-test
|
||||
(:require
|
||||
[backend-tests.helpers :as th]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.db :as db]
|
||||
[app.rpc :as-alias rpc]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]))
|
||||
|
||||
|
@ -104,6 +104,4 @@
|
|||
(t/is (nil? (:error out)))
|
||||
(let [result (:result out)]
|
||||
(t/is (contains? result :file))
|
||||
(t/is (contains? result :project)))))
|
||||
|
||||
))
|
||||
(t/is (contains? result :project)))))))
|
||||
|
|
|
@ -140,9 +140,7 @@
|
|||
error-data (ex-data error)]
|
||||
(t/is (th/ex-info? error))
|
||||
(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
|
||||
(with-mocks [http-mock {:target 'app.http.client/req!
|
||||
|
|
|
@ -50,8 +50,7 @@
|
|||
(t/is (= "data" (:other (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-path storage object))))
|
||||
))
|
||||
(t/is (= "content" (slurp (sto/get-object-path storage object))))))
|
||||
|
||||
(t/deftest put-and-retrieve-expired-object
|
||||
(let [storage (-> (:app.storage/storage th/*system*)
|
||||
|
@ -59,8 +58,7 @@
|
|||
content (sto/content "content")
|
||||
object (sto/put-object! storage {::sto/content content
|
||||
::sto/expired-at (dt/in-future {:seconds 1})
|
||||
:content-type "text/plain"
|
||||
})]
|
||||
:content-type "text/plain"})]
|
||||
|
||||
(t/is (sto/object? 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-data 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
|
||||
(let [storage (-> (:app.storage/storage th/*system*)
|
||||
|
@ -92,8 +89,7 @@
|
|||
|
||||
;; But you can't retrieve the object again because in database is
|
||||
;; 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
|
||||
(let [storage (-> (:app.storage/storage th/*system*)
|
||||
|
@ -103,16 +99,13 @@
|
|||
content3 (sto/content "content3")
|
||||
object1 (sto/put-object! storage {::sto/content content1
|
||||
::sto/expired-at (dt/now)
|
||||
:content-type "text/plain"
|
||||
})
|
||||
:content-type "text/plain"})
|
||||
object2 (sto/put-object! storage {::sto/content content2
|
||||
::sto/expired-at (dt/in-past {:hours 2})
|
||||
:content-type "text/plain"
|
||||
})
|
||||
:content-type "text/plain"})
|
||||
object3 (sto/put-object! storage {::sto/content content3
|
||||
::sto/expired-at (dt/in-past {:hours 1})
|
||||
:content-type "text/plain"
|
||||
})]
|
||||
:content-type "text/plain"})]
|
||||
|
||||
|
||||
(th/sleep 200)
|
||||
|
@ -186,8 +179,7 @@
|
|||
|
||||
;; 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"])]
|
||||
(t/is (= 0 (:count res))))
|
||||
)))
|
||||
(t/is (= 0 (:count res)))))))
|
||||
|
||||
|
||||
(t/deftest test-touched-gc-task-2
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
(ns backend-tests.tasks-telemetry-test
|
||||
(:require
|
||||
[backend-tests.helpers :as th]
|
||||
[app.db :as db]
|
||||
[app.util.time :as dt]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.pprint :refer [pprint]]
|
||||
[clojure.test :as t]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
|
|
@ -60,9 +60,7 @@
|
|||
|
||||
(t/testing "error on non-uuid keys"
|
||||
(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/testing "modified & compact"
|
||||
|
@ -83,8 +81,7 @@
|
|||
(t/is (= (get obj1 id1) (get obj2 id1)))
|
||||
(t/is (= (get obj1 id2) (get obj2 id2)))
|
||||
(t/is (= (count obj1) (count obj2)))
|
||||
(t/is (= (hash obj1) (hash obj2)))))
|
||||
)
|
||||
(t/is (= (hash obj1) (hash obj2))))))
|
||||
|
||||
(t/deftest internal-encode-decode
|
||||
(sg/check!
|
||||
|
|
|
@ -55,8 +55,7 @@
|
|||
(t/is (pmap/pointer-map? obj2))
|
||||
(t/is (identical? tmp obj2))
|
||||
(t/is (= 0 (count obj1)))
|
||||
(t/is (= 0 (count obj2)))))
|
||||
)
|
||||
(t/is (= 0 (count obj2))))))
|
||||
|
||||
|
||||
(t/deftest internal-tracking
|
||||
|
@ -118,7 +117,5 @@
|
|||
(t/is (not (contains? obj1 :b)))
|
||||
(t/is (= 1 (get obj1 :a)))
|
||||
(t/is (= nil (get obj1 :b)))
|
||||
(t/is (= ::empty (get obj1 :b ::empty))))))
|
||||
|
||||
)
|
||||
(t/is (= ::empty (get obj1 :b ::empty)))))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue