Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5ee6ca

Browse files
committed
Updating SQL to expand paths and extract suites.
1 parent 12be123 commit d5ee6ca

2 files changed

Lines changed: 33 additions & 21 deletions

File tree

source/core/ut_suite_cache_manager.pkb

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,41 @@ create or replace package body ut_suite_cache_manager is
151151

152152
return l_results;
153153
end;
154+
154155
/*
155-
The object name is populate but suitepath not
156-
We will use that object and try to match.
157-
We can pass also a wildcard this will result in one to many.
156+
First SQL queries for objects where procedure is null or its only wildcard.
157+
We split that due to fact that we can use func min to combine rows.
158+
159+
Second union is responsible expanding paths where the procedure filter is given
160+
We cannot select min here as filter can cover only half of tests within
161+
package. Even if the filter doesnt return anything we still capture a proc filter
162+
name for error reporting later on.
158163

159-
Get all data that do not have an wildcard and not require expanding.
160-
We will take them as they are.
161-
a)suite path is populated
162-
b)suite path and object is empty so schema name is by default ( or passed)
164+
Third SQL cover scenario where a suitapath only is populated and wildcard is given
165+
166+
Fourth SQL cover scenario where suitepath is populated with no filters
163167
*/
164168
function expand_paths(a_schema_paths ut_path_items) return ut_path_items is
165169
l_schema_paths ut_path_items:= ut_path_items();
166170
begin
167171
with paths_to_expand as (
168172
select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name,
169-
nvl2(sp.procedure_name,c.name,null) as procedure_name
173+
null as procedure_name
174+
from table(a_schema_paths) sp left outer join ut_suite_cache c
175+
on ( c.object_owner = upper(sp.schema_name)
176+
and c.object_name like replace(upper(sp.object_name),'*','%'))
177+
where sp.suite_path is null and sp.object_name is not null
178+
and ( sp.procedure_name is null or sp.procedure_name = '*')
179+
group by sp.schema_name,nvl(c.object_name,sp.object_name)
180+
union all
181+
select /*+ no_parallel */ path as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name,
182+
nvl(c.name,sp.procedure_name) as procedure_name
170183
from table(a_schema_paths) sp left outer join ut_suite_cache c
171184
on ( c.object_owner = upper(sp.schema_name)
172185
and c.object_name like replace(upper(sp.object_name),'*','%')
173186
and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name))
174187
where sp.suite_path is null and sp.object_name is not null
175-
group by sp.schema_name,nvl(c.object_name,sp.object_name),nvl2(sp.procedure_name,c.name,null)
188+
and (sp.procedure_name is not null and sp.procedure_name != '*')
176189
union all
177190
select /*+ no_parallel */ nvl(c.path,sp.suite_path) as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
178191
from
@@ -218,18 +231,17 @@ create or replace package body ut_suite_cache_manager is
218231
from ut_suite_cache c,
219232
table(a_schema_paths) sp
220233
where c.object_owner = upper(sp.schema_name)
221-
and (
222-
(sp.suite_path is not null and
223-
sp.suite_path||'.' like c.path||'.%' /*all parents and self*/
224-
or
225-
( c.path||'.' like sp.suite_path||'.%' /*all children and self*/
226-
and c.object_name like nvl(upper(sp.object_name),c.object_name)
227-
and c.name like nvl(upper(sp.procedure_name),c.name) ) )
234+
and ((sp.suite_path is not null and sp.suite_path||'.' like c.path||'.%' /*all parents and self*/
235+
or
236+
(
237+
c.path||'.' like sp.suite_path||'.%' /*all children and self*/
238+
and c.object_name like nvl(upper(sp.object_name),c.object_name)
239+
and c.name like nvl(upper(sp.procedure_name),c.name)
240+
))
228241
or
229242
( sp.suite_path is null
230-
and c.object_name like nvl(upper(replace(sp.object_name,'*','%')),c.object_name)
231-
and c.name like nvl(upper(replace(sp.procedure_name,'*','%')),c.name)
232-
))) where r_num = 1;
243+
and c.object_name = nvl(upper(sp.object_name),c.object_name)
244+
and c.name = nvl(upper(sp.procedure_name),c.name)))) where r_num =1;
233245
return l_suite_items;
234246
end;
235247

test/ut3_tester/core/test_suite_manager.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,11 +958,11 @@ end;]';
958958
procedure test_search_nonex_prc_wild is
959959
l_objects_to_run ut3_develop.ut_suite_items;
960960
begin
961-
l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop.test_package_1.nonexist*'));
961+
l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_tester.test_package_1.nonexist*'));
962962
ut.fail('Non existing package did not raise exception');
963963
exception
964964
when others then
965-
ut.expect(sqlerrm).to_be_like('%failing_non_*%');
965+
ut.expect(sqlerrm).to_be_like('%nonexist*%');
966966
end;
967967

968968
procedure test_search_nonex_path_wild is

0 commit comments

Comments
 (0)