← 输入框|github.com|刷新
Skip to content

Add to_include matcher for collections and cursors #79

Closed

Description

@jgebal

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

Activity

  1. added this to the milestone on Oct 17, 2016
  2. modified the milestones: , on Dec 18, 2016
  3. removed this from the v3.1.0 milestone on Apr 23, 2018
  4. added and removed on Jun 19, 2018
  5. jgebal commented on Aug 9, 2018

    @jgebal
    MemberAuthor

    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?

  6. lwasylow commented on Aug 10, 2018

    @lwasylow
    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.

  7. self-assigned this
    on Oct 4, 2018
  8. lwasylow commented on Oct 6, 2018

    @lwasylow
    Member

    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 ?

  9. added this to the v3.1.3 milestone on Nov 2, 2018
  10. modified the milestones: v3.1.3, v3.1.4 on Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions