mirror of
https://github.com/penpot/penpot.git
synced 2026-11-27 21:57:52 +00:00
📎 Test binfile import limit configuration
Verify that configured limits decode and reach the importer, and that missing values use the existing defaults. AI-assisted-by: gpt-6.1-terra
This commit is contained in:
parent
640a9665a2
commit
cf4e0ded38
48
backend/test/backend_tests/binfile_config_test.clj
Normal file
48
backend/test/backend_tests/binfile_config_test.clj
Normal file
@ -0,0 +1,48 @@
|
||||
;; 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 SUBSIDIARY SL
|
||||
|
||||
(ns backend-tests.binfile-config-test
|
||||
(:require
|
||||
[app.binfile.common :as bfc]
|
||||
[app.binfile.v3 :as v3]
|
||||
[app.config :as cf]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/deftest import-limits-reach-the-importer
|
||||
(let [values {:binfile-import-max-text-entry-size 101
|
||||
:binfile-import-max-text-total-size 202
|
||||
:binfile-import-max-binary-entry-size 303
|
||||
:binfile-import-max-zip-entries 404}]
|
||||
(binding [cf/config (merge cf/config values)]
|
||||
(doseq [[key value] values]
|
||||
(t/is (= value (cf/get key))))
|
||||
(let [cfg (bfc/import-cfg {} {:team {:features #{}}})
|
||||
resolved (#'v3/setup-limits cfg)]
|
||||
(t/is (= 101 (::bfc/import-max-text-entry-size cfg) (::v3/max-text-entry-size resolved)))
|
||||
(t/is (= 202 (::bfc/import-max-text-total-size cfg) (::v3/max-text-total-size resolved)))
|
||||
(t/is (= 303 (::bfc/import-max-binary-entry-size cfg) (::v3/max-binary-entry-size resolved)))
|
||||
(t/is (= 404 (::bfc/import-max-zip-entries cfg) (::v3/max-zip-entries resolved)))))))
|
||||
|
||||
(t/deftest import-limits-default-when-unconfigured
|
||||
(let [keys [:binfile-import-max-text-entry-size
|
||||
:binfile-import-max-text-total-size
|
||||
:binfile-import-max-binary-entry-size
|
||||
:binfile-import-max-zip-entries]]
|
||||
(binding [cf/config (apply dissoc cf/config keys)]
|
||||
(let [cfg (bfc/import-cfg {} {:team {:features #{}}})
|
||||
resolved (#'v3/setup-limits cfg)
|
||||
other (#'v3/setup-limits cfg)]
|
||||
(t/is (nil? (::bfc/import-max-text-entry-size cfg)))
|
||||
(t/is (nil? (::bfc/import-max-text-total-size cfg)))
|
||||
(t/is (nil? (::bfc/import-max-binary-entry-size cfg)))
|
||||
(t/is (nil? (::bfc/import-max-zip-entries cfg)))
|
||||
(t/is (= bfc/default-max-text-entry-size (::v3/max-text-entry-size resolved)))
|
||||
(t/is (= bfc/default-max-text-total-size (::v3/max-text-total-size resolved)))
|
||||
(t/is (= bfc/default-max-binary-entry-size (::v3/max-binary-entry-size resolved)))
|
||||
(t/is (= bfc/default-max-zip-entries (::v3/max-zip-entries resolved)))
|
||||
(t/is (= 0 @(::v3/accumulated-total-text-size resolved)))
|
||||
(t/is (not (identical? (::v3/accumulated-total-text-size resolved)
|
||||
(::v3/accumulated-total-text-size other))))))))
|
||||
@ -76,6 +76,23 @@
|
||||
:worker-default-parallelism 4)]
|
||||
(t/is (= 4 (cf/get :worker-default-parallelism 1))))))
|
||||
|
||||
(t/deftest binfile-import-limit-keys
|
||||
(let [values {:binfile-import-max-text-entry-size "101"
|
||||
:binfile-import-max-text-total-size "202"
|
||||
:binfile-import-max-binary-entry-size "303"
|
||||
:binfile-import-max-zip-entries "404"}
|
||||
decoded (cf/decode-config values)]
|
||||
(t/is (= {:binfile-import-max-text-entry-size 101
|
||||
:binfile-import-max-text-total-size 202
|
||||
:binfile-import-max-binary-entry-size 303
|
||||
:binfile-import-max-zip-entries 404}
|
||||
decoded))
|
||||
(t/is (cf/validate-config (merge cf/config decoded)))
|
||||
(doseq [key (keys values)]
|
||||
(t/testing (str "non-numeric value for " key)
|
||||
(let [invalid (cf/decode-config (assoc values key "invalid"))]
|
||||
(t/is (not (cf/validate-config (merge cf/config invalid)))))))))
|
||||
|
||||
(t/deftest prepared-statement-cache-keys
|
||||
(t/testing "negative sizes are rejected; the threshold takes -1 or non-negatives"
|
||||
(t/is (not (cf/validate-config (assoc cf/config :database-prepared-statement-cache-queries -1))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user