0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-25 08:16:49 -05:00
penpot/backend/tests/uxbox/tests/test_services_user_attrs.clj
Andrey Antukh 7a5145fa37 ♻️ Big refactor of the default data model.
Introduce teams.
2020-02-17 09:49:04 +01:00

65 lines
2.4 KiB
Clojure

(ns uxbox.tests.test-services-user-attrs
(:require
[clojure.spec.alpha :as s]
[clojure.test :as t]
[promesa.core :as p]
[uxbox.db :as db]
[uxbox.http :as http]
[uxbox.services.mutations :as sm]
[uxbox.services.queries :as sq]
[uxbox.tests.helpers :as th]))
;; (t/use-fixtures :once th/state-init)
;; (t/use-fixtures :each th/database-reset)
;; (t/deftest test-user-attrs
;; (let [{:keys [id] :as user} @(th/create-user db/pool 1)]
;; (let [out (th/try-on! (sq/handle {::sq/type :user-attr
;; :key "foobar"
;; :user id}))]
;; (t/is (nil? (:result out)))
;; (let [error (:error out)]
;; (t/is (th/ex-info? error))
;; (t/is (th/ex-of-type? error :service-error)))
;; (let [error (ex-cause (:error out))]
;; (t/is (th/ex-info? error))
;; (t/is (th/ex-of-type? error :not-found))))
;; (let [out (th/try-on! (sm/handle {::sm/type :upsert-user-attr
;; :user id
;; :key "foobar"
;; :val {:some #{:value}}}))]
;; ;; (th/print-result! out)
;; (t/is (nil? (:error out)))
;; (t/is (nil? (:result out))))
;; (let [out (th/try-on! (sq/handle {::sq/type :user-attr
;; :key "foobar"
;; :user id}))]
;; ;; (th/print-result! out)
;; (t/is (nil? (:error out)))
;; (t/is (= {:some #{:value}} (get-in out [:result :val])))
;; (t/is (= "foobar" (get-in out [:result :key]))))
;; (let [out (th/try-on! (sm/handle {::sm/type :delete-user-attr
;; :user id
;; :key "foobar"}))]
;; ;; (th/print-result! out)
;; (t/is (nil? (:error out)))
;; (t/is (nil? (:result out))))
;; (let [out (th/try-on! (sq/handle {::sq/type :user-attr
;; :key "foobar"
;; :user id}))]
;; ;; (th/print-result! out)
;; (t/is (nil? (:result out)))
;; (let [error (:error out)]
;; (t/is (th/ex-info? error))
;; (t/is (th/ex-of-type? error :service-error)))
;; (let [error (ex-cause (:error out))]
;; (t/is (th/ex-info? error))
;; (t/is (th/ex-of-type? error :not-found))))))