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

Skip to content

Commit 9423457

Browse files
committed
Added test for min user test
1 parent b05dbd7 commit 9423457

4 files changed

Lines changed: 96 additions & 1 deletion

File tree

test/install__min_usr_tests.sql

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
set define off
2+
whenever sqlerror exit failure rollback
3+
whenever oserror exit failure rollback
4+
5+
alter session set plsql_optimize_level=0;
6+
7+
--Install tests
8+
@@min_grant_user/min_grant_user_exp.pks
9+
@@min_grant_user/min_grant_user_exp.pkb
10+
11+
set linesize 200
12+
set define on
13+
set verify off
14+
column text format a100
15+
column error_count noprint new_value error_count
16+
17+
prompt Validating installation
18+
19+
set heading on
20+
select type, name, sequence, line, position, text, count(1) over() error_count
21+
from all_errors
22+
where owner = USER
23+
and name not like 'BIN$%' --not recycled
24+
and name != 'UT_WITH_INVALID_BODY'
25+
-- errors only. ignore warnings
26+
and attribute = 'ERROR'
27+
order by name, type, sequence
28+
/
29+
30+
begin
31+
if to_number('&&error_count') > 0 then
32+
raise_application_error(-20000, 'Not all sources were successfully installed.');
33+
else
34+
dbms_output.put_line('Installation completed successfully');
35+
end if;
36+
end;
37+
/
38+
39+
exit;

test/install_and_run_tests.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
#!/bin/bash
22
set -ev
33

4+
check_result()
5+
{
6+
RC1=$1
7+
RC2=$2
8+
9+
if [ "$RC1" != "0" ] || [ "$RC2" != "0" ]; then
10+
return 1
11+
fi
12+
return 0
13+
}
414

515
#goto git root directory
616
git rev-parse && cd "$(git rev-parse --show-cdup)"
717

18+
cd test
19+
20+
time "$SQLCLI" ${UT3_USER}/${UT3_USER_PASSWORD}@//${CONNECTION_STR} @install__min_usr_tests.sql
21+
22+
cd ..
23+
24+
time utPLSQL-cli/bin/utplsql run ${UT3_USER}/${UT3_USER_PASSWORD}@${CONNECTION_STR} \
25+
-source_path=source -owner=ut3 \
26+
-test_path=test -c \
27+
-f=ut_documentation_reporter -o=min_test_results.log -s \
28+
-scc
29+
30+
status_line_regex="^[0-9]+ tests, ([0-9]+) failed, ([0-9]+) errored.*"
31+
32+
RC1=$(cat min_test_results.log | grep -E "${status_line_regex}" | sed -re "s/${status_line_regex}/\1\2/")
833

934
cd test
1035

@@ -29,6 +54,9 @@ status_line_regex="^[0-9]+ tests, ([0-9]+) failed, ([0-9]+) errored.*"
2954
#cat coverage.xml
3055
#cat test_results.xml
3156

32-
RC=$(cat test_results.log | grep -E "${status_line_regex}" | sed -re "s/${status_line_regex}/\1\2/")
57+
RC2=$(cat test_results.log | grep -E "${status_line_regex}" | sed -re "s/${status_line_regex}/\1\2/")
58+
59+
check_result $RC1 $RC2
60+
RC=$?
3361

3462
exit $RC
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create or replace package body min_grant_user_exp is
2+
3+
procedure test_join_by_cursor is
4+
l_actual SYS_REFCURSOR;
5+
l_expected SYS_REFCURSOR;
6+
begin
7+
--Arrange
8+
open l_actual for select owner, object_name,object_type from all_objects where owner = user
9+
order by 1,2,3 asc;
10+
open l_expected for select owner, object_name,object_type from all_objects where owner = user
11+
order by 1,2,3 desc;
12+
13+
--Act
14+
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER');
15+
16+
end;
17+
18+
end;
19+
/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
create or replace package min_grant_user_exp is
2+
3+
--%suite(minimum grant user tests)
4+
5+
--%test(execute join by test)
6+
procedure test_join_by_cursor;
7+
8+
end;
9+
/

0 commit comments

Comments
 (0)