|
1 | 1 | create or replace package body test_ut_runner is |
2 | 2 |
|
| 3 | + procedure setup_cache_objects is |
| 4 | + pragma autonomous_transaction; |
| 5 | + begin |
| 6 | + execute immediate q'[create or replace package dummy_test_package as |
| 7 | + --%suite(dummy_test_suite) |
| 8 | + --%rollback(manual) |
| 9 | + |
| 10 | + --%test(dummy_test) |
| 11 | + --%beforetest(some_procedure) |
| 12 | + procedure some_dummy_test_procedure; |
| 13 | + end;]'; |
| 14 | + execute immediate q'[create or replace procedure dummy_test_procedure as |
| 15 | + --%some_annotation(some_text) |
| 16 | + --%rollback(manual) |
| 17 | + begin |
| 18 | + null; |
| 19 | + end;]'; |
| 20 | + execute immediate q'[create or replace procedure ut3.dummy_test_procedure as |
| 21 | + --%some_annotation(some_text) |
| 22 | + --%rollback(manual) |
| 23 | + begin |
| 24 | + null; |
| 25 | + end;]'; |
| 26 | + end; |
| 27 | + |
| 28 | + procedure setup_cache is |
| 29 | + pragma autonomous_transaction; |
| 30 | + begin |
| 31 | + setup_cache_objects(); |
| 32 | + ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); |
| 33 | + ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PROCEDURE'); |
| 34 | + ut3.ut_annotation_manager.rebuild_annotation_cache('UT3','PROCEDURE'); |
| 35 | + end; |
| 36 | + |
| 37 | + procedure cleanup_cache is |
| 38 | + pragma autonomous_transaction; |
| 39 | + begin |
| 40 | + delete from ut3.ut_annotation_cache_info |
| 41 | + where object_type = 'PROCEDURE' and object_owner in ('UT3',user) |
| 42 | + or object_type = 'PACKAGE' and object_owner = user and object_name = 'DUMMY_TEST_PACKAGE'; |
| 43 | + execute immediate q'[drop package dummy_test_package]'; |
| 44 | + execute immediate q'[drop procedure dummy_test_procedure]'; |
| 45 | + execute immediate q'[drop procedure ut3.dummy_test_procedure]'; |
| 46 | + end; |
| 47 | + |
3 | 48 | procedure create_test_spec |
4 | 49 | as |
5 | 50 | pragma autonomous_transaction; |
@@ -160,5 +205,58 @@ end;'; |
160 | 205 | drop_test_package(); |
161 | 206 | end; |
162 | 207 |
|
| 208 | + procedure test_purge_cache_schema_type is |
| 209 | + l_actual sys_refcursor; |
| 210 | + begin |
| 211 | + |
| 212 | + open l_actual for |
| 213 | + select * from ut3.ut_annotation_cache_info |
| 214 | + where object_owner = user and object_type = 'PROCEDURE'; |
| 215 | + ut.expect(l_actual).not_to_be_empty(); |
| 216 | + |
| 217 | + --Act |
| 218 | + ut3.ut_runner.purge_cache(user,'PROCEDURE'); |
| 219 | + |
| 220 | + --Assert |
| 221 | + open l_actual for |
| 222 | + select * from ut3.ut_annotation_cache_info |
| 223 | + where object_owner = user and object_type = 'PROCEDURE'; |
| 224 | + --Cache purged for object owner/type |
| 225 | + ut.expect(l_actual).to_be_empty(); |
| 226 | + open l_actual for |
| 227 | + select * from ut3.ut_annotation_cache_info |
| 228 | + where object_owner = user and object_type = 'PACKAGE'; |
| 229 | + --Cache not purged for other types |
| 230 | + ut.expect(l_actual).not_to_be_empty(); |
| 231 | + open l_actual for |
| 232 | + select * from ut3.ut_annotation_cache_info |
| 233 | + where object_owner = 'UT3' and object_type = 'PROCEDURE'; |
| 234 | + --Cache not purged for other owners |
| 235 | + ut.expect(l_actual).not_to_be_empty(); |
| 236 | + |
| 237 | + end; |
| 238 | + |
| 239 | + procedure test_rebuild_cache_schema_type is |
| 240 | + l_actual integer; |
| 241 | + begin |
| 242 | + --Act |
| 243 | + ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); |
| 244 | + --Assert |
| 245 | + select count(1) into l_actual |
| 246 | + from ut3.ut_annotation_cache_info i |
| 247 | + join ut3.ut_annotation_cache c on c.cache_id = i.cache_id |
| 248 | + where object_owner = user and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; |
| 249 | + --Rebuild cache for user/packages |
| 250 | + ut.expect(l_actual).to_equal(4); |
| 251 | + |
| 252 | + select count(1) into l_actual |
| 253 | + from ut3.ut_annotation_cache_info i |
| 254 | + join ut3.ut_annotation_cache c on c.cache_id = i.cache_id |
| 255 | + where object_owner = 'UT3' and object_type = 'PROCEDURE'; |
| 256 | + |
| 257 | + --Did not rebuild cache for ut3/procedures |
| 258 | + ut.expect(l_actual).to_equal(0); |
| 259 | + end; |
| 260 | + |
163 | 261 | end; |
164 | 262 | / |
0 commit comments