On Feb 23, 2012, at 3:08 AM, Peter Eisentraut wrote:

> For (unit) testing, I have often had the need to override the current
> timestamp in the database system.  For example, a column default,
> function, or views would make use of the current timestamp in some way,
> and to test the behavior, it's sometimes useful to tweak the current
> timestamp.
> 
> What might be a good way to do that?
> 
> Just overwrite xactStartTimestamp?  Is that safe?  If it weren't static,
> a user-loaded function could do it.
> 
> Overwrite pg_catalog.now() in the test database?
> 
> Other ideas?
> 
> Some semi-official support for this sort of thing would be good.

I create a "mock" schema, add the function to it, and then put it in the 
search_path ahead of pg_catalog. See the example starting at slide 48 on 
http://www.slideshare.net/justatheory/pgtap-best-practices.

Best,

David


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

Reply via email to