Re: Testing Views

From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: achambers(dot)home(at)googlemail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Testing Views
Date: 2015-05-20 09:55:10
Message-ID: 555C59FE.2070203@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 20/05/15 19:47, Andy Chambers wrote:
> Hello All,
>
> I have a problem for which a view seems like a nice solution.
> Basically we want to see all records in some table that are older than
> 5 days and haven't yet gone through further processing.
>
> This particular view is probably simple enough that it doesn't require
> unit tests but I wonder how people test complex views that depend on
> the current date or time. I found a thread on the hackers list [1]
> that talked about stubbing pg_catalog.now() but was wondering if any
> TDD minded developers had invented anything better since then.
>
> One option I thought of was to just not use views that depend on the
> current date or time and instead create a set returning function that
> takes the time as a parameter. Would such a function have similar
> performance characteristics to an equivalent view?
>
> Cheers,
> Andy
>
> [1]:
> http://postgresql.nabble.com/overriding-current-timestamp-td5507701.html
How about using a 'Time Machine'?

Run the database in a VM and change the date/time. You can take a clone
of the VM, and recreate it multiple times from a known state.

A technique we used to test for Y2K problems, except in those days we
did have Virtual Machines like we have now!

Cheers,
Gavin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mathew Moon 2015-05-20 10:16:34 Re: Memory Utilization Issue
Previous Message François Battail 2015-05-20 09:26:29 Re: Optimizing a read-only database