On Dec 15, 2020, at 02:29, Dimitar Draginov <
dimitar....@gmail.com> wrote:
> Actually, I tried something with some success.
> All the time I was thinking pgTAP should perform as a wrapper of my procs and it looks like this was my problem.
Ah, glad to hear it.
> /*
> -- procedure parameters
> CREATE OR REPLACE FUNCTION imgowner.pkg_image_folder$p_check_folder_changed(
> folder_type character,
> folder_id character,
> OUT folder_item_count integer,
> OUT max_rowscn numeric,
> OUT rowcount_out imgowner."pkg_image_folder$st_rows_affected"
> )
> */
Iām a little confused, as this is a function, not a stored procedure.
> DO $$
> DECLARE
> folder_item_count integer;
> max_rowscn numeric;
> rowcount_out imgowner."pkg_image_folder$st_rows_affected";
> v_ok varchar;
DO does not return any rows, so it wonāt work. Youāll need to write a function and call it, instead.
> Please, review and let me know your suggestions if it can be improved to match real unit testing.
>
> Do I have to remove "psql:TEST_p_check_folder_changed.sql:45: NOTICE:" at the beginning of each row?
I would, as itās not tap. You can use diag(), instead. Try this (untested, may have syntax errors):
BEGIN;
SELECT plan(4);
CREATE TEMPORARY FUNCTION validate_folder(
) RETURNS SETOF TEXT language plgpsql AS $$
DECLARE
folder_item_count integer;
max_rowscn numeric;
rowcount_out imgowner."pkg_image_folder$st_rows_affected";
BEGIN
RETURN NEXT lives_ok(
$l$ call imgowner.pkg_image_folder$p_check_folder_changed(
'PSVA ','VA94000150', folder_item_count, max_rowscn, rowcount_out
);
$l$, 'Should get no error calling p_check_folder_changed');
RETURN NEXT cmp_ok(folder_item_count, '>' 0, 'Should have folder_item_count > 0');
RETURN NEXT cmp_ok(max_rowscn, '>', 0, 'Should have max_rowscn > 0');
RETURN NEXT cmp_ok(rowcount_out, '>', 0, 'Should have rowcount_out > 0');
END;
$$;
SELECT * FROM validate_folder();
SELECT * FROM finish();
ROLLBACK;
HTH,
David