Re: Thoughts on "Love Your Database" - Mailing list pgsql-general

From Chris Travers
Subject Re: Thoughts on "Love Your Database"
Date
Msg-id CAKt_ZftOg5fYVBASnwnjPG76C45JTb9QVJ=paHSDMoJMJo0tSA@mail.gmail.com
Whole thread Raw
In response to Re: Thoughts on "Love Your Database"  (Guyren Howe <guyren@gmail.com>)
Responses Re: Thoughts on "Love Your Database"  (Szymon Lipiński <mabewlun@gmail.com>)
List pgsql-general


On Fri, May 20, 2016 at 10:43 PM, Guyren Howe <guyren@gmail.com> wrote:
On May 20, 2016, at 13:38 , Pierre Chevalier Géologue <pierrechevaliergeol@free.fr> wrote:
>
> Le 04/05/2016 18:29, Szymon Lipiński a écrit :
>> On the other hand, when I was trying to store all my logic in a
>> database, there was just one thing that made me hate it. Testing.
>> Testing the procedures inside the database was not easy, not funny, and
>> too much time consuming.
>
> Yes, very good point.

Are there any best practices or tricks to make this easier?

Strangely I have never had a problem testing stored procedures.  You have to create a data set for the tests of course and that is the hardest part, but there are some really nice things:

1.  If your test scripts always roll back you can run them on a production database as a troubleshooting step
2.  It is easy to hook things up to a TAP harness (whether using PgTAP or some hand-rolled solution).  I think it would be harder to connect to xunit though.  So use TAP ;-)
3.  I usually create a test results table (in my test case, rolled back after!) which stores the test description and pass status.  That makes it easy to check using other tools.

Usually I set aside a range of things (negative id's for example) for testing purposes.
 

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.

pgsql-general by date:

Previous
From: Szymon Lipiński
Date:
Subject: Re: Thoughts on "Love Your Database"
Next
From: "dandl"
Date:
Subject: How to know if SPI or some other API triggered an ERROR.