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
> 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.
In response to
pgsql-hackers by date
|Next:||From: David E. Wheeler||Date: 2012-02-23 18:55:53|
|Subject: Re: overriding current_timestamp|
|Previous:||From: Kevin Grittner||Date: 2012-02-23 18:44:50|
|Subject: Re: foreign key locks, 2nd attempt|