Architecture & practice·Design, structure and tradeoffs
the business rules import the Postgres driver, so testing a discount calculation needs a database.
Dependency inversion
Also calleddependency inversion principle, ports and adapters, hexagonal architecture
Making the important code depend on an interface it defines, and the infrastructure depend on that interface too, so the arrow points inward instead of outward. The practical effect is that the rules of your business can be tested and understood without a network, a database or a cloud account. It is the backbone of the ports-and-adapters argument, and the reason a senior engineer will push back on a domain object that knows what a HTTP status code is.