🔧 Change CI configuration.

This commit is contained in:
Andrey Antukh 2021-03-30 15:35:18 +02:00 committed by Alonso Torres
parent 0926fbcbc6
commit 351daacca0
5 changed files with 27 additions and 20 deletions

View file

@ -13,7 +13,7 @@ jobs:
environment: environment:
POSTGRES_USER: penpot_test POSTGRES_USER: penpot_test
POSTGRES_PASSWORD: penpot_test POSTGRES_PASSWORD: penpot_test
POSTGRES_DB: penpot POSTGRES_DB: penpot_test
- image: circleci/redis:6.0.8 - image: circleci/redis:6.0.8
@ -45,10 +45,10 @@ jobs:
name: backend test name: backend test
command: "clojure -M:dev:tests" command: "clojure -M:dev:tests"
environment: environment:
PENPOT_DATABASE_URI: "postgresql://localhost/penpot" PENPOT_TEST_DATABASE_URI: "postgresql://localhost/penpot_test"
PENPOT_DATABASE_USERNAME: penpot_test PENPOT_TEST_DATABASE_USERNAME: penpot_test
PENPOT_DATABASE_PASSWORD: penpot_test PENPOT_TEST_DATABASE_PASSWORD: penpot_test
PENPOT_REDIS_URI: "redis://localhost/1" PENPOT_TEST_REDIS_URI: "redis://localhost/1"
- run: - run:
working_directory: "./frontend" working_directory: "./frontend"

View file

@ -32,7 +32,7 @@
{:http-server-port 6060 {:http-server-port 6060
:host "devenv" :host "devenv"
:tenant "dev" :tenant "dev"
:database-uri "postgresql://127.0.0.1/penpot" :database-uri "postgresql://postgres/penpot"
:database-username "penpot" :database-username "penpot"
:database-password "penpot" :database-password "penpot"

View file

@ -38,11 +38,22 @@
(def ^:dynamic *system* nil) (def ^:dynamic *system* nil)
(def ^:dynamic *pool* nil) (def ^:dynamic *pool* nil)
(def defaults
{:database-uri "postgresql://postgres/penpot_test"
:redis-uri "redis://redis/1"})
(def config
(->> (cf/read-env "penpot-test")
(merge cf/defaults defaults)
(us/conform ::cf/config)))
(defn state-init (defn state-init
[next] [next]
(let [config (-> main/system-config (let [config (-> main/system-config
(assoc-in [:app.msgbus/msgbus :redis-uri] "redis://redis/1") (assoc-in [:app.msgbus/msgbus :redis-uri] (:redis-uri config))
(assoc-in [:app.db/pool :uri] "postgresql://postgres/penpot_test") (assoc-in [:app.db/pool :uri] (:database-uri config))
(assoc-in [:app.db/pool :username] (:database-username config))
(assoc-in [:app.db/pool :password] (:database-password config))
(assoc-in [[:app.main/main :app.storage.fs/backend] :directory] "/tmp/app/storage") (assoc-in [[:app.main/main :app.storage.fs/backend] :directory] "/tmp/app/storage")
(dissoc :app.srepl/server (dissoc :app.srepl/server
:app.http/server :app.http/server
@ -325,9 +336,9 @@
[data] [data]
(fn (fn
([key] ([key]
(get data key (cf/get key))) (get data key (get @cf/config key)))
([key default] ([key default]
(get data key (cf/get key default))))) (get data key (get @cf/config key default)))))
(defn reset-mock! (defn reset-mock!
[m] [m]

View file

@ -21,10 +21,6 @@
(t/use-fixtures :once th/state-init) (t/use-fixtures :once th/state-init)
(t/use-fixtures :each th/database-reset) (t/use-fixtures :each th/database-reset)
;; (with-mocks [mock {:target 'app.tasks/submit! :return nil}]
;; Right now we have many different scenarios what can cause a
;; bounce/complain report.
(defn- decode-row (defn- decode-row
[{:keys [content] :as row}] [{:keys [content] :as row}]
(cond-> row (cond-> row

View file

@ -132,7 +132,7 @@
(t/is (nil? result))) (t/is (nil? result)))
;; Request profile to be deleted ;; Request profile to be deleted
(with-mocks [mock {:target 'app.tasks/submit! :return nil}] (with-mocks [mock {:target 'app.worker/submit! :return nil}]
(let [params {::th/type :delete-profile (let [params {::th/type :delete-profile
:profile-id (:id prof)} :profile-id (:id prof)}
out (th/mutation! params)] out (th/mutation! params)]
@ -140,11 +140,11 @@
;; check the mock ;; check the mock
(let [mock (deref mock) (let [mock (deref mock)
mock-params (second (:call-args mock))] mock-params (first (:call-args mock))]
(t/is (:called? mock)) (t/is (:called? mock))
(t/is (= 1 (:call-count mock))) (t/is (= 1 (:call-count mock)))
(t/is (= "delete-profile" (:name mock-params))) (t/is (= :delete-profile (:app.worker/task mock-params)))
(t/is (= (:id prof) (get-in mock-params [:props :profile-id])))))) (t/is (= (:id prof) (:profile-id mock-params))))))
;; query files after profile soft deletion ;; query files after profile soft deletion
(let [params {::th/type :files (let [params {::th/type :files
@ -257,8 +257,8 @@
:terms-privacy true} :terms-privacy true}
out (th/mutation! data)] out (th/mutation! data)]
;; (th/print-result! out) ;; (th/print-result! out)
(let [mock (deref mock) (let [mock (deref mock)
[_ _ params] (:call-args mock)] [params] (:call-args mock)]
;; (clojure.pprint/pprint params) ;; (clojure.pprint/pprint params)
(t/is (:called? mock)) (t/is (:called? mock))
(t/is (= (:email data) (:to params))) (t/is (= (:email data) (:to params)))