On 8/14/25 08:51, 'Matt DeLuco' via pgTAP Users wrote:
> Yes, your approach seems inline with the “verify” tests from the
> sqitch documentation.
>
> But as my database and my DB functions evolve over time, so must their
> unit tests (testing for current behaviours, as you describe.) So my
> question is more around keeping my pgTAP tests up to date, and how
> those tests are migrated along with the DB changes.
>
Hi Matt,
Like Logan, I find most changes are pretty minimal once you get things
up and running, so it's easy enough to manually update the tests.
That being said, what to do when first implementing a DB or if you add
several new tables and such? Well, assuming you have a "gold standard
DB" (or a DB you *know* to be correct), you could use that DB to create
your tests to check the table, columns, types, defaults, indexes, FKs,
etc., or so the theory goes. To that end, I wrote a Perl program to go
thru the various pg_catalog & information_schema tables & views and
create the pgTap tests to verify structure. There are a few things it
doesn't do, but it does the majority of the work of writing the tests
for you. Having used it for a while, I can see ways to add to it and
perhaps I will soon (reason below). [Note, I don't use sqitch so I don't
know if this fits with what you do or not. Obviously, it can't create
your business function result tests, but just keep a separate file for
that.]
David,
I'm willing to donate the tool to help out other Pg admins/users. It
doesn't belong in the pgTap extension, but is an auxiliary tool. Would
you be willing to put it on on the pgTap website for download? Or
perhaps a sub-dir under "tools" in the github repo would be better? Of
if you'd prefer, I could create a github project for it and you could
mention it exists.
<plug class=hopeful>I was laid off this week (and I might have some
extra time to work on things like this very soon). So if anyone is
looking for a developer who knows Pg, please contact me directly. I live
in the DFW area, but remote work is fine too. My email should be in the
FROM email header.</plug>
Kevin