mirror of
https://github.com/penpot/penpot.git
synced 2025-08-02 12:38:31 +02:00
🎉 Add conditional reading to RPC
This commit is contained in:
parent
5192b36669
commit
fde03e21b0
12 changed files with 242 additions and 90 deletions
42
backend/test/backend_tests/rpc_cond_middleware_test.clj
Normal file
42
backend/test/backend_tests/rpc_cond_middleware_test.clj
Normal file
|
@ -0,0 +1,42 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns backend-tests.rpc-cond-middleware-test
|
||||
(:require
|
||||
[backend-tests.storage-test :refer [configure-storage-backend]]
|
||||
[backend-tests.helpers :as th]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.db :as db]
|
||||
[app.http :as http]
|
||||
[app.rpc.cond :as cond]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
(t/deftest conditional-requests
|
||||
(let [profile (th/create-profile* 1 {:is-active true})
|
||||
project (th/create-project* 1 {:team-id (:default-team-id profile)
|
||||
:profile-id (:id profile)})
|
||||
file1 (th/create-file* 1 {:profile-id (:id profile)
|
||||
:project-id (:id project)})
|
||||
params {::th/type :get-file :id (:id file1) :profile-id (:id profile)}]
|
||||
|
||||
(binding [cond/*enabled* true]
|
||||
(let [{:keys [error result]} (th/command! params)]
|
||||
(t/is (nil? error))
|
||||
(t/is (map? result))
|
||||
(t/is (contains? (meta result) :app.http/headers))
|
||||
(t/is (contains? (meta result) :app.rpc.cond/key))
|
||||
|
||||
(let [etag (-> result meta :app.http/headers (get "etag"))
|
||||
{:keys [error result]} (th/command! (assoc params ::cond/key etag))]
|
||||
(t/is (nil? error))
|
||||
(t/is (fn? result))
|
||||
(t/is (= 304 (-> (result nil) :status))))
|
||||
))))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue