Andrey Antukh fe8a305811 🐛 Fix RPC test helper dropping injected request metadata
The push-audit-events initiator test injects a request with
:app.http/auth-key-id via :app.http/request metadata. prepare-rpc-params
always replaced that metadata with a fresh DummyRequest, so the key id
was lost and the initiator fell back to "app".

Honor a caller-supplied request map, merging body params into its
:params, and keep the dummy request only for non-map IRequest stubs
(reify requests used by the audit tests, which cannot be assoc'd).

Add focused regression tests for the three cases and document the
helper contract in the backend testing memory.

AI-assisted-by: deepseek-v4.1-flash
2026-09-24 11:42:14 +02:00

1.3 KiB

Backend Testing

JVM clojure.test (kaocha runner) under backend/test/backend_tests/.

  • READ mem:testing FIRST — it defines the execution discipline (no piping, tee to file, preferred commands) that applies to all JVM test runs.
  • All CLI commands must be executed from the backend/ subdirectory.
  • Tests are invoked directly via clojure -M:dev:test (kaocha) — there is no pnpm wrapper. Kaocha auto-discovers test namespaces, so no runner registration is needed.
  • Coverage: if code is added or modified in src/, corresponding tests in test/backend_tests/ must be added or updated.
  • Isolated run: clojure -M:dev:test --focus backend-tests.my-ns-test for a specific test namespace, or clojure -M:dev:test --focus backend-tests.my-ns-test/my-test-var for a specific test var.
  • Regression run: clojure -M:dev:test to ensure no regressions in related functional areas.
  • If you need to filter output, tee to a temp file first: clojure -M:dev:test 2>&1 | tee /tmp/penpot-test-output.txt.
  • RPC test helpers command!/management-command! split the data map: qualified keys become server params, unqualified keys become request body params. To inject request-level context (headers, :app.http/auth-key-id, ip), pass a map under :app.http/request metadata; non-map IRequest stubs fall back to a dummy request.