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

refactor(open/openapi/validate): return promises, fix tests #410

Merged
merged 9 commits into from
Dec 21, 2021

Conversation

kanadgupta
Copy link
Member

@kanadgupta kanadgupta commented Dec 21, 2021

🧰 Changes

This rabbit hole of work is a continuation of the work started in #407 where I'm combing through and making sure we're returning resolved/rejected promises wherever possible and updating/standardizing our test suite patterns to ensure better coverage and to make debugging easier. In an effort to keep this PR easy to review (since most of the diff is just testbed refactors), I'm going to only include a few command refactors here:

  1. open
    • Command updates
      • Refactored the main function so we're always returning a resolved/rejected promise
    • Testbed updates
      • Removed all console.log mocks
      • Refactored tests to use standard patterns and check for promise return value
  2. openapi
    • Command updates
      • Refactored the main function so we're always returning a resolved/rejected promise
    • Testbed updates
      • Removed all console.log mocks
        • I wasn't able to fully remove the console mocks since I figured we'd still want to check for certain console outputs, but I refactored them to be console.info and console.warn calls so we can safely use console.log for our own debugging.
      • Refactored tests to use standard patterns and check for promise return value
        • In the process of doing this, I discovered several gaping holes in our test coverage due to nock value typos! The tests feel much more airtight now 🎉
  3. validate
    • Command updates
      • Refactored the main function so we're always returning a resolved/rejected promise
    • Testbed updates
      • Removed all console.log mocks
        • Similar to the openapi command above, we're now using console.info instead.
      • Refactored tests to use standard patterns and check for promise return value

In separate PRs, I'll be doing the following:

🧬 QA & Testing

Note that this PR doesn't actually fix any bugs in the main codebase itself, just standardizes our patterns and fixes a few test suite issues. If tests pass and you can run the above commands as expected, then we should be good to go.

- console.info is so we can safely use console.log() statements when debugging more easily

- returning the value allows us to write more robust tests
- returning the value allows us to write more robust tests
- console.info() makes it so it's easier for us to use console.log while debugging
- returning the promise allows us to write more robust tests
This reverts commit afeaf7b.

For the sake of confining the scope of these changes, I'm reverting this and will fix this in a separate PR focused on our docs commands.
@kanadgupta kanadgupta requested a review from erunion December 21, 2021 21:30
@erunion erunion added bug enhancement New feature or request labels Dec 21, 2021
Copy link
Member

@erunion erunion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super minor comments but these are all great refactors

Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.com>
@erunion erunion merged commit 8b9ad4b into main Dec 21, 2021
@erunion erunion deleted the refactor/return-promises-where-possible branch December 21, 2021 22:12
@kanadgupta kanadgupta added the refactor Issues about tackling technical debt label Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Issues about tackling technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants