Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad results for failing standalone expectations on compound data #998

Closed
jgebal opened this issue Sep 22, 2019 · 0 comments · Fixed by #999
Labels
bug
Milestone

Comments

@jgebal
Copy link
Member

@jgebal jgebal commented Sep 22, 2019

Describe the bug
When running standalone expectations in a single session and having more than one failing expectation, the results returned by report are wrong.
This is probably also observable in regular run,when running more than one cursor/object comparison in single test.

Provide version info
utPLSQL v3.1.8

To Reproduce

clear screen
set serverout on
declare
  l_actual   sys_refcursor;
  l_expected sys_refcursor;
begin
  open l_actual   for select rownum rn from dual connect by level < 5;
  open l_expected for select rownum rn from dual connect by level = 1;
  ut.expect(l_actual).to_equal(l_expected);
  open l_actual   for select rownum rn from dual connect by level < 3;
  open l_expected for select * from (select rownum rn from dual connect by level < 3) order by 1 desc;
  ut.expect(l_actual).to_equal(l_expected);
end;
/
rollback;

This produces output:

FAILURE
  Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 1 ]
  Diff:
  Rows: [ 3 differences ]
    Row No. 2 - Extra:    <RN>2</RN>
    Row No. 3 - Extra:    <RN>3</RN>
    Row No. 4 - Extra:    <RN>4</RN>
  at "anonymous block", line 7
FAILURE
  Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
  Diff:
  Rows: [ 2 differences ]
    Row No. 1 - Actual:   <RN>1</RN>
    Row No. 1 - Expected: <RN>2</RN>
    Row No. 2 - Actual:   <RN>2</RN>
    Row No. 2 - Expected: <RN>1</RN>
    Row No. 2 - Extra:    <RN>2</RN>
    Row No. 3 - Extra:    <RN>3</RN>
    Row No. 4 - Extra:    <RN>4</RN>
  at "anonymous block", line 10

However adding a commit or rollback in between expectations fixes the issue.

clear screen
set serverout on
declare
  l_actual   sys_refcursor;
  l_expected sys_refcursor;
begin
  open l_actual   for select rownum rn from dual connect by level < 5;
  open l_expected for select rownum rn from dual connect by level = 1;
  ut.expect(l_actual).to_equal(l_expected);
  rollback;
  open l_actual   for select rownum rn from dual connect by level < 3;
  open l_expected for select * from (select rownum rn from dual connect by level < 3) order by 1 desc;
  ut.expect(l_actual).to_equal(l_expected);
end;
/
rollback;
FAILURE
  Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 1 ]
  Diff:
  Rows: [ 3 differences ]
    Row No. 2 - Extra:    <RN>2</RN>
    Row No. 3 - Extra:    <RN>3</RN>
    Row No. 4 - Extra:    <RN>4</RN>
  at "anonymous block", line 7
FAILURE
  Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
  Diff:
  Rows: [ 2 differences ]
    Row No. 1 - Actual:   <RN>1</RN>
    Row No. 1 - Expected: <RN>2</RN>
    Row No. 2 - Actual:   <RN>2</RN>
    Row No. 2 - Expected: <RN>1</RN>
  at "anonymous block", line 11

Expected behavior
Diff reports should always provide valid outputs.

To fix this, we can delete the diff table as part of diff cleanup.

@jgebal jgebal added the bug label Sep 22, 2019
jgebal added a commit that referenced this issue Sep 22, 2019
Columns:
 - ITEM_DATA
 - DATA_ID
 - ITEM_NO
 - DUP_NO
 - POSITION
Can now be safely used in cursors.
Resolves #997

Added delete on DIFF temp tables after cursor / object compare.
Resolves #998
jgebal added a commit that referenced this issue Sep 22, 2019
Columns:
 - ITEM_DATA
 - DATA_ID
 - ITEM_NO
 - DUP_NO
 - POSITION
Can now be safely used in cursors.
Resolves #997

Added delete on DIFF temp tables after cursor / object compare.
Resolves #998
@jgebal jgebal added this to the 3.1.9 milestone Sep 22, 2019
@jgebal jgebal closed this in #999 Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.