penpot/backend/test/backend_tests/srepl_cli_test.clj
Francis Santiago 290923f0ae ✨ Add bulk profile deletion CLI
Allow administrative tools to submit a list of profile emails through the
structured PREPL interface instead of evaluating Clojure expressions.

Reuse the existing audited deletion path and expose the command through
manage.py for automated maintenance jobs.

AI-assisted-by: gpt-5
2026-09-22 20:42:53 +02:00

33 lines
1.3 KiB
Clojure

;; 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 Sucursal en España SL
(ns backend-tests.srepl-cli-test
(:require
[app.srepl.cli :as cli]
[app.system :as system]
[clojure.test :as t]))
(t/deftest delete-profiles-in-bulk-command
(let [received (atom nil)]
(with-redefs [system/system {:service :test}
cli/delete-profiles! (fn [system emails]
(reset! received [system emails])
{:deleted 2 :total 2})]
(t/is (= {:deleted 2 :total 2}
(cli/exec {:cmd "delete-profiles-in-bulk"
:params {:emails ["one@example.com"
"two@example.com"]}})))
(t/is (= [{:service :test}
["one@example.com" "two@example.com"]]
@received)))))
(t/deftest delete-profiles-in-bulk-requires-emails
(t/is (thrown-with-msg?
clojure.lang.ExceptionInfo
#"non-empty email list"
(cli/exec {:cmd "delete-profiles-in-bulk"
:params {:emails []}}))))