0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-02 04:19:08 -05:00

Improve test runner

This commit is contained in:
Andrey Antukh 2022-09-21 00:46:22 +02:00
parent 2348146f00
commit ec53288b66
5 changed files with 18 additions and 20 deletions

View file

@ -71,7 +71,8 @@
{:extra-paths ["test"] {:extra-paths ["test"]
:extra-deps :extra-deps
{io.github.cognitect-labs/test-runner {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}} {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test} :exec-fn cognitect.test-runner.api/test}
:outdated :outdated

View file

@ -11,7 +11,6 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.exceptions :as ex] [app.common.exceptions :as ex]
[app.common.flags :as flags] [app.common.flags :as flags]
[app.common.logging :as l]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.version :as v] [app.common.version :as v]
[app.util.time :as dt] [app.util.time :as dt]
@ -359,11 +358,7 @@
"%version%"))) "%version%")))
(defonce ^:dynamic config (read-config)) (defonce ^:dynamic config (read-config))
(defonce ^:dynamic flags (parse-flags config))
(defonce ^:dynamic flags
(let [flags (parse-flags config)]
(l/info :hint "flags initialized" :flags (str/join "," (map name flags)))
flags))
(def deletion-delay (def deletion-delay
(dt/duration {:days 7})) (dt/duration {:days 7}))

View file

@ -10,6 +10,7 @@
[app.common.logging :as l] [app.common.logging :as l]
[app.config :as cf] [app.config :as cf]
[app.util.time :as dt] [app.util.time :as dt]
[cuerdas.core :as str]
[integrant.core :as ig]) [integrant.core :as ig])
(:gen-class)) (:gen-class))
@ -417,6 +418,7 @@
(ig/prep) (ig/prep)
(ig/init)))) (ig/init))))
(l/info :msg "welcome to penpot" (l/info :msg "welcome to penpot"
:flags (str/join "," (map name cf/flags))
:worker? (contains? cf/flags :backend-worker) :worker? (contains? cf/flags :backend-worker)
:version (:full cf/version))) :version (:full cf/version)))

View file

@ -301,10 +301,7 @@
(t/is (th/ex-of-code? error :email-as-password))))) (t/is (th/ex-of-code? error :email-as-password)))))
(t/deftest test-email-change-request (t/deftest test-email-change-request
(with-mocks [email-send-mock {:target 'app.emails/send! :return nil} (with-mocks [email-send-mock {:target 'app.emails/send! :return nil}]
cfg-get-mock {:target 'app.config/get
:return (th/mock-config-get-with
{:smtp-enabled true})}]
(let [profile (th/create-profile* 1) (let [profile (th/create-profile* 1)
pool (:app.db/pool th/*system*) pool (:app.db/pool th/*system*)
data {::th/type :request-email-change data {::th/type :request-email-change

View file

@ -50,6 +50,11 @@
(merge cf/defaults defaults) (merge cf/defaults defaults)
(us/conform ::cf/config))) (us/conform ::cf/config)))
(def default-flags
[:enable-secure-session-cookies
:enable-email-verification
:enable-smtp])
(defn state-init (defn state-init
[next] [next]
(let [templates [{:id "test" (let [templates [{:id "test"
@ -57,8 +62,7 @@
:file-uri "test" :file-uri "test"
:thumbnail-uri "test" :thumbnail-uri "test"
:path (-> "app/test_files/template.penpot" io/resource fs/path)}] :path (-> "app/test_files/template.penpot" io/resource fs/path)}]
config (-> main/system-config system (-> (merge main/system-config main/worker-config)
(merge main/worker-config)
(assoc-in [:app.redis/redis :uri] (:redis-uri config)) (assoc-in [:app.redis/redis :uri] (:redis-uri config))
(assoc-in [:app.db/pool :uri] (:database-uri config)) (assoc-in [:app.db/pool :uri] (:database-uri config))
(assoc-in [:app.db/pool :username] (:database-username config)) (assoc-in [:app.db/pool :username] (:database-username config))
@ -75,7 +79,6 @@
:app.auth.oidc/generic-provider :app.auth.oidc/generic-provider
:app.setup/builtin-templates :app.setup/builtin-templates
:app.auth.oidc/routes :app.auth.oidc/routes
;; :app.auth.ldap/provider
:app.worker/executors-monitor :app.worker/executors-monitor
:app.http.oauth/handler :app.http.oauth/handler
:app.notifications/handler :app.notifications/handler
@ -86,16 +89,16 @@
:app.loggers.zmq/receiver :app.loggers.zmq/receiver
:app.worker/cron :app.worker/cron
:app.worker/worker)) :app.worker/worker))
_ (ig/load-namespaces config) _ (ig/load-namespaces system)
system (-> (ig/prep config) system (-> (ig/prep system)
(ig/init))] (ig/init))]
(try (try
(binding [*system* system (binding [*system* system
*pool* (:app.db/pool system)] *pool* (:app.db/pool system)]
(mk/with-mocks [mock1 {:target 'app.rpc.commands.auth/derive-password (with-redefs [app.config/flags (flags/parse flags/default default-flags (:flags config))
:return identity} app.config/config config
mock2 {:target 'app.rpc.commands.auth/verify-password app.rpc.commands.auth/derive-password identity
:return (fn [a b] {:valid (= a b)})}] app.rpc.commands.auth/verify-password (fn [a b] {:valid (= a b)})]
(next))) (next)))
(finally (finally
(ig/halt! system))))) (ig/halt! system)))))