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

Skip to content

Commit c79afbd

Browse files
committed
Trying to test ut3 using ut3 framework installed in separate schema.
1 parent 248b243 commit c79afbd

5 files changed

Lines changed: 239 additions & 3 deletions

File tree

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ env:
2626
- UT3_RELEASE_VERSION_SCHEMA=UT3_LATEST_RELEASE
2727
- UT3_USER="UT3\$USER#"
2828
- UT3_USER_PASSWORD=ut3
29+
- UT3_TESTER=ut3_tester
30+
- UT3_TESTER_PASSWORD=UT3
2931
- UT3_TABLESPACE=users
3032
# Environment for building a release
3133
- CURRENT_BRANCH=${TRAVIS_BRANCH}
@@ -78,6 +80,7 @@ script:
7880
- if [ "${TRAVIS_TAG}" = "" ]; then bash .travis/install.sh; fi
7981
- if [ "${TRAVIS_TAG}" = "" ]; then bash .travis/install_utplsql_release.sh; fi
8082
- if [ "${TRAVIS_TAG}" = "" ]; then bash .travis/run_examples_and_tests.sh; fi
83+
- if [ "${TRAVIS_TAG}" = "" ]; then bash tests/install_and_run_tests.sh; fi
8184
- if [ "${TRAVIS_TAG}" = "" ] && [ "${TRAVIS_REPO_SLUG}" = "${UTPLSQL_REPO}" ]; then sonar-scanner; fi
8285
- if [ "${TRAVIS_TAG}" = "" ]; then bash .travis/coveralls_uploader.sh; fi
8386
- bash .travis/build_docs.sh

.travis/install.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,30 @@ set verify off
1010
@install_headless.sql $UT3_OWNER $UT3_OWNER_PASSWORD
1111
SQL
1212

13+
#additional privileges to run scripted tests
1314
"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
1415
set feedback on
1516
--needed for Mystats script to work
1617
grant select any dictionary to $UT3_OWNER;
1718
--Needed for testing a coverage outside ut3_owner.
1819
grant create any procedure, drop any procedure, execute any procedure to $UT3_OWNER;
1920
20-
set feedback off
21-
@create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE
22-
2321
conn $UT3_OWNER/$UT3_OWNER_PASSWORD@//$CONNECTION_STR
2422
@../development/utplsql_style_check.sql
23+
exit
24+
SQL
2525

26+
#Create additional users
27+
"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
28+
set feedback off
29+
@create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE
30+
@create_utplsql_owner.sql $UT3_TESTER $UT3_TESTER_PASSWORD $UT3_TABLESPACE
31+
exit
32+
SQL
33+
34+
"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
35+
set feedback on
36+
--Needed for testing coverage outside of main UT3 schema.
37+
grant create any procedure, drop any procedure, execute any procedure to $UT3_TESTER;
2638
exit
2739
SQL

tests/run_tests.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -ev
3+
#replace "/" with "@"
4+
conn_str=${CONNECTION_STR//\//@}
5+
6+
"$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} <<-SQL
7+
@ut_utils/test_ut_utils.pks
8+
@ut_utils/test_ut_utils.pkb
9+
exit
10+
SQL
11+
12+
utPLSQL-cli/bin/utplsql run ${UT3_TESTER}/${UT3_TESTER_PASSWORD}${conn_str} \
13+
-source_path=source -test_path=tests \
14+
-f=ut_documentation_reporter -c \
15+
-f=ut_coverage_sonar_reporter -o=coverage.xml \
16+
-f=ut_sonar_test_reporter -o=test_results.xml

tests/ut_utils/test_ut_utils.pkb

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
create or replace package body test_ut_utils as
2+
3+
procedure clob_to_table_test(
4+
a_clob clob, a_expected ut_varchar2_list,
5+
a_delimiter varchar2 := ',',
6+
a_overflow_limit integer := 1000
7+
) is
8+
l_result ut_varchar2_list;
9+
begin
10+
--Act
11+
l_result := ut3.ut_utils.clob_to_table(a_clob, a_overflow_limit, a_delimiter);
12+
--Assert
13+
ut.expect(anydata.convertCollection(l_result)).to_( equal(anydata.convertCollection(a_expected)) );
14+
end;
15+
16+
procedure clob_to_table_by_delim is
17+
begin
18+
clob_to_table_test( a_clob => 'a,b,c,d', a_expected => ut_varchar2_list('a','b','c','d') );
19+
end;
20+
21+
--%test(clob_to_table returns empty table for null clob)
22+
procedure clob_to_table_null_data is
23+
begin
24+
clob_to_table_test( a_clob => null, a_expected => ut_varchar2_list() );
25+
end;
26+
27+
--%test(clob_to_table splits table by char limit when no delimiter)
28+
procedure clob_to_table_char_limit is
29+
begin
30+
clob_to_table_test(
31+
a_clob => '1,2,3,4',
32+
a_expected => ut_varchar2_list('1,2,','3,4'),
33+
a_delimiter => '',
34+
a_overflow_limit => 4
35+
);
36+
end;
37+
38+
--%test(clob_to_table splits table by char limit on overflow and continues by delimiter)
39+
procedure clob_to_table_char_limit_delim is
40+
begin
41+
clob_to_table_test(
42+
a_clob => 'abcdefg,hijk,axa,a',
43+
a_expected => ut_varchar2_list('abc','def','g','hij','k','axa','a'),
44+
a_overflow_limit => 3
45+
);
46+
end;
47+
48+
--%test(clob_to_table returns empty lines for null data between delimiter)
49+
procedure clob_to_table_empty_lines is
50+
begin
51+
clob_to_table_test(
52+
a_clob => ',a,,c,d,',
53+
a_expected => ut_varchar2_list('','a','','c','d','')
54+
);
55+
end;
56+
57+
--%test(test_result_to_char)
58+
procedure test_result_to_char is
59+
begin
60+
ut.expect( ut_utils.test_result_to_char(NULL)).to_equal('Unknown(NULL)');
61+
ut.expect( ut_utils.test_result_to_char(-1)).to_equal('Unknown(-1)');
62+
ut.expect( ut_utils.test_result_to_char(ut_utils.tr_disabled)).to_equal(ut_utils.tr_disabled_char);
63+
ut.expect( ut_utils.test_result_to_char(ut_utils.tr_success)).to_equal(ut_utils.tr_success_char);
64+
ut.expect( ut_utils.test_result_to_char(ut_utils.tr_failure)).to_equal(ut_utils.tr_failure_char);
65+
ut.expect( ut_utils.test_result_to_char(ut_utils.tr_error)).to_equal(ut_utils.tr_error_char);
66+
end;
67+
68+
--%test(to_test_result converts boolean value to test result integer)
69+
procedure to_test_result is
70+
begin
71+
ut.expect( ut_utils.to_test_result(true)).to_equal(ut_utils.tr_success);
72+
ut.expect( ut_utils.to_test_result(false)).to_equal(ut_utils.tr_failure);
73+
ut.expect( ut_utils.to_test_result(null)).to_equal(ut_utils.tr_failure);
74+
end;
75+
76+
--%test(to_string on null blob)
77+
procedure to_string_null_blob is
78+
begin
79+
ut.expect( ut_utils.to_string(to_blob(null)) ).to_equal('NULL');
80+
end;
81+
82+
--%test(to_string on blob)
83+
procedure to_string_blob is
84+
l_text varchar2(32767) := 'A test char';
85+
l_value blob := utl_raw.cast_to_raw(l_text);
86+
l_expected varchar2(32767) := ''''||rawtohex(l_value)||'''';
87+
begin
88+
ut.expect( ut_utils.to_string(l_value) ).to_equal(l_expected);
89+
end;
90+
91+
-- --%test(to_string on null clob)
92+
-- procedure to_string_null_clob;
93+
-- --%test(to_string on clob)
94+
-- procedure to_string_clob;
95+
-- --%test(to_string on clob no surrounding quotes)
96+
-- procedure to_string_clob_no_quotes;
97+
-- --%test(to_string on clob other surrounding quotes)
98+
-- procedure to_string_clob_other_quotes;
99+
--
100+
-- --%test(to_string on null number)
101+
-- procedure to_string_null_number;
102+
-- --%test(to_string on number)
103+
-- procedure to_string_number;
104+
--
105+
-- --%test(to_string on null timestamp)
106+
-- procedure to_string_null_timestamp;
107+
-- --%test(to_string on timestamp)
108+
-- procedure to_string_timestamp;
109+
--
110+
-- --%test(to_string on null timestamp with time zone)
111+
-- procedure to_string_null_timestamp_tz;
112+
-- --%test(to_string on timestamp with time zone)
113+
-- procedure to_string_timestamp_tz;
114+
--
115+
-- --%test(to_string on null timestamp with local time zone)
116+
-- procedure to_string_null_timestamp_ltz;
117+
-- --%test(to_string on timestamp with local time zone)
118+
-- procedure to_string_timestamp_ltz;
119+
--
120+
-- --%test(to_string on null varchar)
121+
-- procedure to_string_null_varchar;
122+
-- --%test(to_string on varchar)
123+
-- procedure to_string_varchar;
124+
-- --%test(to_string on varchar no surrounding quotes)
125+
-- procedure to_string_varchar_no_quotes;
126+
-- --%test(to_string on varchar non default surrounding quotes)
127+
-- procedure to_string_varchar_other_quotes;
128+
129+
end;
130+
/

tests/ut_utils/test_ut_utils.pks

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
create or replace package test_ut_utils as
2+
3+
--%suite(Testing common utility package: ut_utils)
4+
--%suitepath(org.utplsql.utplsql.ut_utils)
5+
6+
--%context(clob_to_table)
7+
8+
--%test(splits clob by delimiter)
9+
procedure clob_to_table_by_delim;
10+
11+
--%test(returns empty table for null clob)
12+
procedure clob_to_table_null_data;
13+
14+
--%test(splits table by char limit when no delimiter)
15+
procedure clob_to_table_char_limit;
16+
17+
--%test(splits table by char limit on overflow and continues by delimiter)
18+
procedure clob_to_table_char_limit_delim;
19+
20+
--%test(returns empty lines for null data between delimiter)
21+
procedure clob_to_table_empty_lines;
22+
23+
--%endcontext
24+
25+
--%test(test_result_to_char)
26+
procedure test_result_to_char;
27+
28+
--%test(to_test_result converts boolean value to test result integer)
29+
procedure to_test_result;
30+
31+
--%test(to_string on null blob)
32+
procedure to_string_null_blob;
33+
--%test(to_string on blob)
34+
procedure to_string_blob;
35+
36+
-- --%test(to_string on null clob)
37+
-- procedure to_string_null_clob;
38+
-- --%test(to_string on clob)
39+
-- procedure to_string_clob;
40+
-- --%test(to_string on clob no surrounding quotes)
41+
-- procedure to_string_clob_no_quotes;
42+
-- --%test(to_string on clob other surrounding quotes)
43+
-- procedure to_string_clob_other_quotes;
44+
--
45+
-- --%test(to_string on null number)
46+
-- procedure to_string_null_number;
47+
-- --%test(to_string on number)
48+
-- procedure to_string_number;
49+
--
50+
-- --%test(to_string on null timestamp)
51+
-- procedure to_string_null_timestamp;
52+
-- --%test(to_string on timestamp)
53+
-- procedure to_string_timestamp;
54+
--
55+
-- --%test(to_string on null timestamp with time zone)
56+
-- procedure to_string_null_timestamp_tz;
57+
-- --%test(to_string on timestamp with time zone)
58+
-- procedure to_string_timestamp_tz;
59+
--
60+
-- --%test(to_string on null timestamp with local time zone)
61+
-- procedure to_string_null_timestamp_ltz;
62+
-- --%test(to_string on timestamp with local time zone)
63+
-- procedure to_string_timestamp_ltz;
64+
--
65+
-- --%test(to_string on null varchar)
66+
-- procedure to_string_null_varchar;
67+
-- --%test(to_string on varchar)
68+
-- procedure to_string_varchar;
69+
-- --%test(to_string on varchar no surrounding quotes)
70+
-- procedure to_string_varchar_no_quotes;
71+
-- --%test(to_string on varchar non default surrounding quotes)
72+
-- procedure to_string_varchar_other_quotes;
73+
74+
end;
75+
/

0 commit comments

Comments
 (0)