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

Skip to content

Commit 43b8754

Browse files
committed
Fixed output buffer and related test.
1 parent 19ac972 commit 43b8754

4 files changed

Lines changed: 22 additions & 38 deletions

File tree

old_tests/ut_output_buffer/get_lines.WaitsForMoreDataToAppearForSpecifiedTime.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ begin
1818
if ut_expectation_processor.get_status = ut_utils.tr_success then
1919
:test_result := ut_utils.tr_success;
2020
else
21-
dbms_output.put_line(ut_expectation_processor.get_expectations_results()(1).get_result_clob);
21+
dbms_output.put_line(ut_expectation_processor.get_failed_expectations()(1).get_result_clob);
2222
end if;
2323
end;
2424
/

source/core/output_buffers/ut_output_buffer_tmp.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ create table ut_output_buffer_tmp$(
2121
message_id number(38,0) not null,
2222
text varchar2(4000),
2323
is_finished number(1,0) default 0 not null,
24-
start_date date not null,
2524
constraint ut_output_buffer_tmp_pk primary key(output_id, message_id),
2625
constraint ut_output_buffer_tmp_ck check(is_finished = 0 and text is not null or is_finished = 1 and text is null),
2726
constraint ut_output_buffer_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id)
2827
) organization index overflow nologging initrans 100
2928
;
3029

31-
create index ut_output_buffer_tmp_i on ut_output_buffer_tmp$(start_date) initrans 100 nologging;
32-
3330
-- This is needed to be EBR ready as editioning view can only be created by edition enabled user
3431
declare
3532
ex_nonedition_user exception;
@@ -62,7 +59,6 @@ select output_id
6259
,message_id
6360
,text
6461
,is_finished
65-
,start_date
6662
from ut_output_buffer_tmp$';
6763

6864
execute immediate 'create or replace editioning view '||v_view_source;

test/core/test_output_buffer.pkb

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,29 @@ create or replace package body test_output_buffer is
44
l_result varchar2(4000);
55
l_remaining integer;
66
l_expected varchar2(4000);
7-
l_reporter ut3.ut_reporter_base :=ut3. ut_documentation_reporter();
7+
l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
88
begin
99
--Act
1010
l_expected := lpad('a text',4000,',a text');
11-
ut3.ut_output_buffer.send_line(l_reporter, l_expected);
11+
l_buffer.send_line(l_expected);
1212

13-
select * into l_result from table(ut3.ut_output_buffer.get_lines(l_reporter.reporter_id,0));
13+
select * into l_result from table(l_buffer.get_lines(0,0));
1414

1515
ut.expect(l_result).to_equal(l_expected);
1616

17-
select count(1) into l_remaining from ut3.ut_output_buffer_tmp where reporter_id = l_reporter.reporter_id;
17+
select count(1) into l_remaining from ut3.ut_output_buffer_tmp where output_id = l_buffer.output_id;
1818

1919
ut.expect(l_remaining).to_equal(0);
2020
end;
2121

22-
procedure test_doesnt_send_on_null_id is
23-
l_cur sys_refcursor;
24-
begin
25-
delete from ut3.ut_output_buffer_tmp;
26-
--Act
27-
ut3.ut_output_buffer.send_line(null,'a text to send');
28-
29-
open l_cur for select * from ut3.ut_output_buffer_tmp;
30-
31-
ut.expect(l_cur).to_be_empty;
32-
end;
33-
3422
procedure test_doesnt_send_on_null_text is
35-
l_cur sys_refcursor;
23+
l_cur sys_refcursor;
3624
l_result integer;
37-
l_reporter ut3.ut_reporter_base := ut3.ut_documentation_reporter();
25+
l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
3826
begin
3927
delete from ut3.ut_output_buffer_tmp;
4028
--Act
41-
ut3.ut_output_buffer.send_line(l_reporter,null);
29+
l_buffer.send_line(null);
4230

4331
open l_cur for select * from ut3.ut_output_buffer_tmp;
4432
ut.expect(l_cur).to_be_empty;
@@ -47,30 +35,33 @@ create or replace package body test_output_buffer is
4735
procedure test_send_line is
4836
l_result varchar2(4000);
4937
c_expected constant varchar2(4000) := lpad('a text',4000,',a text');
50-
l_reporter ut3.ut_reporter_base := ut3.ut_documentation_reporter();
38+
l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
5139
begin
52-
ut3.ut_output_buffer.send_line(l_reporter, c_expected);
40+
l_buffer.send_line(c_expected);
5341

54-
select text into l_result from ut3.ut_output_buffer_tmp where reporter_id = l_reporter.reporter_id;
42+
select text into l_result from ut3.ut_output_buffer_tmp where output_id = l_buffer.output_id;
5543

5644
ut.expect(l_result).to_equal(c_expected);
5745
end;
5846

5947
procedure test_waiting_for_data is
60-
l_result varchar2(4000);
48+
l_result varchar2(4000);
6149
l_remaining integer;
62-
l_expected varchar2(4000);
63-
l_reporter ut3.ut_reporter_base := ut3.ut_documentation_reporter();
50+
l_expected varchar2(4000);
51+
l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
52+
l_start timestamp;
53+
l_duration interval day to second;
6454
begin
6555
--Act
6656
l_expected := lpad('a text',4000,',a text');
67-
ut3.ut_output_buffer.send_line(l_reporter, l_expected);
68-
69-
select * into l_result from table(ut3.ut_output_buffer.get_lines(l_reporter.reporter_id,0));
57+
l_buffer.send_line(l_expected);
58+
l_start := systimestamp;
59+
select * into l_result from table(l_buffer.get_lines(1,1));
60+
l_duration := systimestamp - l_start;
7061

7162
ut.expect(l_result).to_equal(l_expected);
72-
73-
select count(1) into l_remaining from ut3.ut_output_buffer_tmp where reporter_id = l_reporter.reporter_id;
63+
ut.expect(l_duration).to_be_greater_than(interval '1' second);
64+
select count(1) into l_remaining from ut3.ut_output_buffer_tmp where output_id = l_buffer.output_id;
7465

7566
ut.expect(l_remaining).to_equal(0);
7667

test/core/test_output_buffer.pks

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ create or replace package test_output_buffer is
66
--%test(Recieves a line from buffer table and deletes)
77
procedure test_recieve;
88

9-
--%test(Does not send line if null reporter id given)
10-
procedure test_doesnt_send_on_null_id;
11-
129
--%test(Does not send line if null text given)
1310
procedure test_doesnt_send_on_null_text;
1411

0 commit comments

Comments
 (0)