Skip to content

Add to_include matcher for collections and cursors #79

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

Closed
jgebal opened this issue Oct 17, 2016 · 3 comments
Closed

Add to_include matcher for collections and cursors #79

jgebal opened this issue Oct 17, 2016 · 3 comments
Assignees
Milestone

Comments

@jgebal
Copy link
Member

jgebal commented Oct 17, 2016

The inclusion matcher should allow us to tell that actual collection / cursor is a superset of the expected (includes expected)

@jgebal jgebal added this to the version3 milestone Oct 17, 2016
@jgebal jgebal modified the milestones: version3.1, version3 Dec 18, 2016
@jgebal jgebal removed this from the v3.1.0 milestone Apr 23, 2018
@jgebal jgebal added idea and removed task labels Jun 19, 2018
@jgebal
Copy link
Member Author

jgebal commented Aug 9, 2018

A test should fail if expected set contains elements that are not part of actual set.
The exclude/include/join_by should still be respected.
The order should not be relevant, so the behavior should be unordered by default.
The unordered should not be supported

The simplified SQL representation of that comparison would be something like:

--ut.expect(actual).to_include(expected).join_by(pk) 
--ut.expect(actual).to_contain(expected).join_by(pk) 
select *
  from expected
    left join actual 
   on expected.pk = actual.pk
 where actual.row is null;

--ut.expect(actual).to_include(expected)
--ut.expect(actual).to_contain(expected)
select *
  from expected
    left join actual 
   on expected.row_hash = actual.row_hash
 where actual.row_hash is null;

The not_to_inculde should behave differently. As it should fail if any of rows that are expected is included.

--ut.expect(actual).to_include(expected).join_by(pk) 
--ut.expect(actual).to_contain(expected).join_by(pk) 
select *
  from expected
    left join actual 
   on expected.pk = actual.pk
 where actual.pk is not null;

--ut.expect(actual).to_include(expected)
--ut.expect(actual).to_contain(expected)
select *
  from expected
    left join actual 
   on expected.row_hash = actual.row_hash
 where actual.row_hash is not null;

Do you think it's worth implementing?
@lwasylow - do you think it would it be difficult to add?

@lwasylow
Copy link
Member

No I don't think it will be hard to implement.
However join_by in such scenarios I think will not give benefit at all as we still want to match a content of the full row so regardless of match on key.

Example:

  1. Included fully ( no feedback to user needed possibly)
    2.Not included fully (present result as Expected and Missing )
  2. Partially included ( pk key exists however data content is different, but from logic point of view answer should be still Not Included )

Overall we looking on left outer join instead of full join on existing queries so yeah we should be able to do that fairly easy.

@lwasylow lwasylow self-assigned this Oct 4, 2018
@lwasylow
Copy link
Member

lwasylow commented Oct 6, 2018

Do we want to actually highlight differences as well ?
E.g. PK match but value in column is different ?
Or we want to treat that as missing ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants