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

exclusion patterns #21

Open
robmurtha opened this issue Feb 18, 2016 · 3 comments
Open

exclusion patterns #21

robmurtha opened this issue Feb 18, 2016 · 3 comments

Comments

@robmurtha
Copy link

As a Tester
I want to Exclude variable data (timestamps, id fields etc.)
So that I can validate things that matter

Proposed feature

Designate a pattern that will be used to "erase" values from both the expected data, and the response.

Possible solutions

Use a special character field / operator to indicate the exclusion, in this example the prefix ! designates a type of expression being provided.

Text Patterns
Substitute using sed style replace, mostly for text.
!s: s/ABCDE/XXXXX/g

Remove data matching regex, in this case a valid email address. Any value matching the regex would be replaced with nothing.

!r: (?:[a-z0-9!#$%&'+/=?^{|}~-]+(?:.[a-z0-9!#$%&'_+/=?^_{|}~-]+)|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])")@(?:(?:a-z0-9?.)+a-z0-9?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])+)])

JSON Patterns
Replace a field's contents with a dummy value.
!_id: 123

Exclude field from json, the field "_id" field and value would be removed prior to compare.
!x: _id

@matryer
Copy link
Owner

matryer commented Feb 19, 2016

This would be great when asserting explicit bodies, but I think that kind of assertion on data isn't very useful anyway. Annoyingly, orders of objects (map) and even arrays aren't always predictable, so perhaps more Testify style "assert contains" ideas would work?

But this idea also addresses potential security issues (if passwords are sent around), although I'm keen to avoid solving things like that in the early stages.

@robmurtha
Copy link
Author

Ok, one of the main goals would be to start with a known result that can be pasted into the document and then exclude things like timestamps and ids when running the test to avoid common mismatches. I'll play around with something simple with one syntax using a real example, thanks!

@matryer
Copy link
Owner

matryer commented Feb 19, 2016

Awesome, yeah I’d love to see an example.

On 19 Feb 2016, at 14:48, Rob Murtha [email protected] wrote:

Ok, one of the main goals would be to start with a known result that can be pasted into the document and then exclude things like timestamps and ids when running the test to avoid common mismatches. I'll play around with something simple with one syntax using a real example, thanks!


Reply to this email directly or view it on GitHub #21 (comment).

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