tests/sql/example2.sql .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)
Result: PASS
Meanwhile the following two fail like they just don't see what's inside the do-end block
begin;
do $$
begin
perform plan(1);
perform pass('ok');
perform * from finish();
end; $$;
rollback;
tests/sql/example.sql .. No subtests run
Test Summary Report
-------------------
tests/sql/example.sql (Wstat: 0 Tests: 0 Failed: 0)
Parse errors: No plan found in TAP output
Files=1, Tests=0, 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)
Result: FAIL
begin;
select plan(1);
do $$
begin
perform pass('ok');
end; $$;
select * from finish();
rollback;
tests/sql/example3.sql .. Failed 1/1 subtests
Test Summary Report
-------------------
tests/sql/example3.sql (Wstat: 0 Tests: 0 Failed: 0)
Parse errors: Bad plan. You planned 1 tests but ran 0.
Files=1, Tests=0, 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)
Result: FAIL
P.S I want to use do-end block because it offers declare block
where i can do some initializations like id uuid := uuid_generate_v4()