pgtap icon indicating copy to clipboard operation
pgtap copied to clipboard

Unable to test procedures

Open jnasbyupgrade opened this issue 6 months ago • 1 comments

Based on what pgTap functions are available, I thought that you could use all the function testing functions (ie, is_definer()) to test procedures. Turns out... not so much...

+not ok 1 - Function _task.task__run_for(text, int, task.task_options, boolean) should exist
+# Failed test 1: "Function _task.task__run_for(text, int, task.task_options, boolean) should exist"
+ok 2 - Function task.task__run_for(text, int, task.task_options, boolean) should be a procedure
+not ok 3 - Function _task.task__run_for(text, int, task.task_options, boolean) should be security definer
+# Failed test 3: "Function _task.task__run_for(text, int, task.task_options, boolean) should be security definer"
+#     (test result was NULL)
+not ok 4 - Function _task.task__run_for(text, int, task.task_options, boolean) should be VOLATILE
+# Failed test 4: "Function _task.task__run_for(text, int, task.task_options, boolean) should be VOLATILE"
+#     Function _task.task__run_for(text, int, task.task_options, boolean) does not exist
+not ok 5 - Function _task.task__run_for(text, int, task.task_options, boolean) should not be strict
+# Failed test 5: "Function _task.task__run_for(text, int, task.task_options, boolean) should not be strict"
+#     (test result was NULL)

The two possibilities that come to mind are:

  1. change the existing functions to recognize both functions and procedures
  2. create a duplicate set of functions for just procedures

I'm leaning towards 1 just to reduce the number of functions in the extension.

jnasbyupgrade avatar Jun 20 '25 21:06 jnasbyupgrade

I agree 1 is worth trying. I suspect it means updating the use of pg_proc.prokind in a WHERE clause.

theory avatar Jun 23 '25 15:06 theory

see #359

c2main avatar Dec 12 '25 18:12 c2main