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

feat(oas): merge example rules #1313

Merged
merged 8 commits into from
Sep 15, 2020
Merged

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Aug 26, 2020

This is a follow-up PR.
See #1284 (comment) for the reasoning.

tl;dr we no longer need such granular rules, as given can be an array of paths now.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

@P0lip P0lip added enhancement New feature or request breaking Pull requests that introduce a breaking change labels Aug 26, 2020
@P0lip P0lip self-assigned this Aug 26, 2020
@nulltoken
Copy link
Contributor

@P0lip Great job! One thought though. There are a lot of code duplication among the tests, and some tests exist in some file and not in others (format related ones IIRC for instance).

What would you think of extracting the valid/invalid schemas and the matching props of the results we'd like to check in one global collection, and then "inject" the schemas in proper locations of base documents in each test? We may have to tweak the expectations regarding the resulting paths, but it's possible this would greatly reduce the size of the diff and (maybe) make those tests a bit easier to maintain and reason about?

@P0lip
Copy link
Contributor Author

P0lip commented Sep 14, 2020

Agree re duplication. It bothers me too.

What would you think of extracting the valid/invalid schemas and the matching props of the results we'd like to check in one global collection, and then "inject" the schemas in proper locations of base documents in each test?

Hm, not sure I'm following. What do you exactly suggest?

@philsturgeon
Copy link
Contributor

There's a few approaches to avoid duplication:

  1. jest.each
  2. defining common schema in a context (outside of it()) and just tweaking it a bit for each one, instead of redefining the whole thing
  3. make some "fixture files"

I'm usually quite content with 1 or 2 but 3 can lead to awkward changes when multiple people do different things with the fixtures.

Also keep in mind we don't need to fix this now, if we keep on boy scouting as we go it'll get better over time.

@nulltoken
Copy link
Contributor

@P0lip My thoughts were around a combination of @philsturgeon points 1 & 2. However, I'm also fine with the we don't need to fix this now, if we keep on boy scouting as we go it'll get better over time way. You've done a tremendous job and maybe refactoring the examples would just deserve a neat issue to keep track of it

@P0lip
Copy link
Contributor Author

P0lip commented Sep 15, 2020

@nulltoken @philsturgeon alright, did some deduplication.
We could probably do a little bit more here and there, but it should be already much better

@P0lip P0lip merged commit a34d1a5 into develop Sep 15, 2020
@P0lip P0lip deleted the feat/merge-schema-example-rules branch September 15, 2020 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Pull requests that introduce a breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants