0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-25 06:01:46 -05:00

feat(backend): adapt tests to route initialization change

This commit is contained in:
Andrey Antukh 2019-07-02 17:13:50 +02:00
parent be7e8e63ee
commit dd6015b329
9 changed files with 39 additions and 40 deletions

View file

@ -55,7 +55,6 @@
(try
(handler (transform request) respond raise)
(catch Exception e
(prn handler)
(raise e))))))))})
(def ^:private multipart-params-middleware

View file

@ -19,7 +19,7 @@
:email "user1@uxbox.io"}
user (with-open [conn (db/connection)]
(usu/create-user conn data))]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [data {:username "user1"
:password "user1"
:metadata "1"
@ -37,7 +37,7 @@
:email "user1@uxbox.io"}
user (with-open [conn (db/connection)]
(usu/create-user conn data))]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [data {:username "user1"
:password "user2"
:metadata "2"

View file

@ -18,7 +18,7 @@
data {:user (:id user)
:name "coll1"}
coll (icons/create-collection conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icon-collections")
[status data] (th/http-get user uri)]
;; (println "RESPONSE:" status data)
@ -28,7 +28,7 @@
(t/deftest test-http-create-icon-collection
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icon-collections")
data {:user (:id user)
:name "coll1"}
@ -45,7 +45,7 @@
data {:user (:id user)
:name "coll1"}
coll (icons/create-collection conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icon-collections/" (:id coll))
params {:body (assoc coll :name "coll2")}
[status data] (th/http-put user uri params)]
@ -61,7 +61,7 @@
:name "coll1"
:data #{1}}
coll (icons/create-collection conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icon-collections/" (:id coll))
[status data] (th/http-delete user uri)]
(t/is (= 204 status))
@ -72,7 +72,7 @@
(t/deftest test-http-create-icon
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icons")
data {:name "sample.jpg"
:content "<g></g>"
@ -99,7 +99,7 @@
:metadata {}
:collection nil}
icon (icons/create-icon conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icons/" (:id icon))
params {:body (assoc icon :name "my stuff")}
[status data] (th/http-put user uri params)]
@ -117,7 +117,7 @@
:metadata {}
:collection nil}
icon (icons/create-icon conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icons/" (:id icon) "/copy")
body {:collection nil}
params {:body body}
@ -137,7 +137,7 @@
:metadata {}
:collection nil}
icon (icons/create-icon conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icons/" (:id icon))
[status data] (th/http-delete user uri)]
(t/is (= 204 status))
@ -154,7 +154,7 @@
:metadata {}
:collection nil}
icon (icons/create-icon conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/icons")
[status data] (th/http-get user uri)]
;; (println "RESPONSE:" status data)

View file

@ -21,7 +21,7 @@
data {:user (:id user)
:name "coll1"}
coll (images/create-collection conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/image-collections")
[status data] (th/http-get user uri)]
;; (println "RESPONSE:" status data)
@ -31,7 +31,7 @@
(t/deftest test-http-create-image-collection
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/image-collections")
data {:user (:id user)
:name "coll1"}
@ -48,7 +48,7 @@
data {:user (:id user)
:name "coll1"}
coll (images/create-collection conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/image-collections/" (:id coll))
params {:body (assoc coll :name "coll2")}
[status data] (th/http-put user uri params)]
@ -64,7 +64,7 @@
:name "coll1"
:data #{1}}
coll (images/create-collection conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/image-collections/" (:id coll))
[status data] (th/http-delete user uri)]
(t/is (= 204 status))
@ -75,7 +75,7 @@
(t/deftest test-http-create-image
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/images")
parts [{:name "sample.jpg"
:part-name "upload"
@ -102,7 +102,7 @@
:mimetype "image/png"
:collection nil}
img (images/create-image conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/images/" (:id img))
params {:body (assoc img :name "my stuff")}
[status data] (th/http-put user uri params)]
@ -126,7 +126,7 @@
:mimetype "image/jpg"
:collection nil}
img (images/create-image conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/images/" (:id img) "/copy")
body {:id (:id img)
:collection nil}
@ -149,7 +149,7 @@
:mimetype "image/png"
:collection nil}
img (images/create-image conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/images/" (:id img))
[status data] (th/http-delete user uri)]
(t/is (= 204 status))
@ -168,7 +168,7 @@
:mimetype "image/png"
:collection nil}
img (images/create-image conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/library/images")
[status data] (th/http-get user uri)]
;; (println "RESPONSE:" status data)

View file

@ -21,7 +21,7 @@
(t/is (nil? (kvs/retrieve-kvstore conn {:user id :key "foo" :version -1})))
;; Creating new one should work as expected
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/kvstore/foo")
body {:value "bar" :version -1}
params {:body body}
@ -37,7 +37,7 @@
(t/is (= (:value data) "bar"))
;; Overwriting should work
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/kvstore/foo")
body (assoc data :value "baz")
_ (prn body)
@ -53,7 +53,7 @@
(t/is (= (:value data) "baz")))
;; Delete should work
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/kvstore/foo")
[status data] (th/http-delete user uri)]
;; (println "RESPONSE:" status data)

View file

@ -17,7 +17,7 @@
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)
proj (uspr/create-project conn {:user (:id user) :name "proj1"})]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/pages")
params {:body {:project (:id proj)
:name "page1"
@ -48,7 +48,7 @@
:height 200
:layout "mobil"}
page (uspg/create-page conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ (str "/api/pages/" (:id page)))
params {:body (assoc page :data "3")}
[status page'] (th/http-put user uri params)]
@ -74,7 +74,7 @@
:height 200
:layout "mobil"}
page (uspg/create-page conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ (str "/api/pages/" (:id page) "/metadata"))
params {:body (assoc page :data "3")}
[status page'] (th/http-put user uri params)]
@ -100,7 +100,7 @@
:height 200
:layout "mobil"}
page (uspg/create-page conn data)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ (str "/api/pages/" (:id page)))
[status response] (th/http-delete user uri)]
;; (println "RESPONSE:" status response)
@ -125,7 +125,7 @@
:layout "mobil"}
page1 (uspg/create-page conn (assoc data :project (:id proj1)))
page2 (uspg/create-page conn (assoc data :project (:id proj2)))]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ (str "/api/pages?project=" (:id proj1)))
[status response] (th/http-get user uri)]
;; (println "RESPONSE:" status response)
@ -158,7 +158,7 @@
(t/is (= (count result) 101)))
;; Check retrieve all items
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/pages/" (:id page) "/history")
[status result] (th/http-get user uri nil)]
;; (println "RESPONSE:" status result)
@ -201,7 +201,7 @@
result (sc/fetch conn [sql (:id data)])
item (first result)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+
"/api/pages/" (:id page)
"/history/" (:id item))

View file

@ -17,7 +17,7 @@
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)
proj (uspr/create-project conn {:user (:id user) :name "proj1"})]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/projects")
[status data] (th/http-get user uri)]
(t/is (= 200 status))
@ -26,7 +26,7 @@
(t/deftest test-http-project-create
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/projects")
params {:body {:name "proj1"}}
[status data] (th/http-post user uri params)]
@ -39,7 +39,7 @@
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)
proj (uspr/create-project conn {:user (:id user) :name "proj1"})]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/projects/" (:id proj))
params {:body (assoc proj :name "proj2")}
[status data] (th/http-put user uri params)]
@ -52,7 +52,7 @@
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)
proj (uspr/create-project conn {:user (:id user) :name "proj1"})]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/projects/" (:id proj))
[status data] (th/http-delete user uri)]
(t/is (= 204 status))
@ -76,7 +76,7 @@
:height 200
:layout "mobil"})
shares (uspr/get-share-tokens-for-project conn (:id proj))]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [token (:token (first shares))
uri (str th/+base-url+ "/api/projects/by-token/" token)
[status data] (th/http-get user uri)]

View file

@ -59,7 +59,7 @@
;; (let [image (slurp (io/resource "uxbox/tests/_files/sample2.svg"))
;; path "/api/svg/parse"
;; user (th/create-user conn 1)]
;; (th/with-server {:handler http/app}
;; (th/with-server {:handler @http/app}
;; (let [rsp (th/request {:method :post
;; :path path
;; :body image

View file

@ -16,7 +16,7 @@
(t/deftest test-http-retrieve-profile
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/profile/me")
[status data] (th/http-get user uri)]
;; (println "RESPONSE:" status data)
@ -30,7 +30,7 @@
(t/deftest test-http-update-profile
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/profile/me")
data (assoc user
:fullname "Full Name"
@ -49,7 +49,7 @@
(t/deftest test-http-update-profile-photo
(with-open [conn (db/connection)]
(let [user (th/create-user conn 1)]
(th/with-server {:handler http/app}
(th/with-server {:handler @http/app}
(let [uri (str th/+base-url+ "/api/profile/me/photo")
params [{:name "sample.jpg"
:part-name "file"