This is great, thanks! (Sorry for the slow reply, work gets in the way...)
Do you know of a way I can use that setup for multiple tests? If I have a bunch of rows to set up, it would be nice to only have to do that setup once.
BEGIN;
SELECT plan(1);
-- perform a test with values from the factory function
WITH
my_rec AS (SELECT * FROM build_rec_for_test()),
my_child_1 AS (SELECT * FROM build_child_for_test(parent_id = (SELECT id FROM my_rec)),
my_grandchild_1 AS (SELECT * FROM build_grandchild_for_test(parent_id = (SELECT id FROM my_child_1)),
...and so on...
SELECT is(
(SELECT id FROM my_rec),
(SELECT parent_id FROM my_child_1)
),
--- and here is non-sql, but just something to illustrate the question
SELECT is(
(SELECT id FROM my_child_1),
(SELECT parent_id FROM my_grandchild_1)
);
--- and so on...
SELECT * FROM finish();
ROLLBACK;
I'm trying to find a clever way to hide all that in yet another function, and somehow return my_rec, my_child_1, and my_grandchild_1 in a single type, but i don't have that level of postgres knowledge yet...
Thanks again!