Choosing Between Parameterized Connections and Wrapper Structs for Racket DB Mocking
0 reputation · 07 Dec 2025, 22:54 UTC
The goal is to write database‑integration tests that never use production credentials while keeping the test suite reliable and maintainable. Two documented strategies exist: rebinding the keyword arguments of `racket/db`'s `make-connection` with `parameterize` to inject test values, or defining a lightweight struct that carries connection details and passing an instance to query functions so tests can supply dummy values.
Constraints include ensuring that the parameter overrides are honoured by the underlying driver (no accidental real network calls), supporting older `racket/db` releases that lack the parameter‑friendly keyword arguments, and balancing the explicit‑dependency benefits of the wrapper struct against the boilerplate and refactoring effort it introduces. Which approach guarantees that `make-connection` uses the overridden parameters without risking a real connection? How does each choice affect the amount of code change required and the support for static analysis? Are there version‑specific caveats that make one strategy safer for projects constrained to pre‑6.12 `racket/db` releases?