Re: Unit tests and foreign key constraints - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Unit tests and foreign key constraints
Date
Msg-id 20150521212920.GB18278@svana.org
Whole thread Raw
In response to Re: Unit tests and foreign key constraints  (Dave Owens <dave@teamunify.com>)
List pgsql-general
On Thu, May 21, 2015 at 01:33:46PM -0700, Dave Owens wrote:
> >
> > I know some say your unit tests shouldn't touch the DB but the more full
> > stack tests I have, the better I sleep at night :-))
> >
>
> Unit tests really should be about testing individual bits of logic.  Does a
> single method do the desired thing, and not the undesired thing...
> Ideally, your data access layer should be interchangeable, ie: use a real
> database record in production, but use a mock database record for unit
> tests.

Nice in theory. But if you use Postgres features like timestamptz
calculations and hstore, it's generally way easier to run your unit
tests on an actual PostgreSQL database.  Otherwise you're going to spend
all your time working around the fact that your mock database is not
the real thing (and running into bugs in your emulation layer).

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
   -- Arthur Schopenhauer

Attachment

pgsql-general by date:

Previous
From: "Karsten Hilbert"
Date:
Subject: Re: date with month and year
Next
From: Paul Jungwirth
Date:
Subject: Re: date with month and year