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

Replace unit test assertions with Gomega matchers #1046

Merged
merged 6 commits into from
Sep 11, 2023

Conversation

bjee19
Copy link
Contributor

@bjee19 bjee19 commented Sep 8, 2023

Proposed changes

Problem: There were still some existing unit tests that weren't using the Gomega matcher library for assertions.

Solution: Changed existing tests to use the Gomega matcher library. In addition, I replaced the deprecated NewGomegaWithT with NewWithT.

Testing: Unit tests still pass

Closes #823

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@bjee19 bjee19 requested a review from a team as a code owner September 8, 2023 17:03
@github-actions github-actions bot added the tech-debt Short-term pain, long-term benefit label Sep 8, 2023
@bjee19
Copy link
Contributor Author

bjee19 commented Sep 8, 2023

There are a couple of situations where Fatal/Fatalf is used and I wasn't sure if I should change that to a Gomega assertion. Fatal/Fatalf logs a message then calls FailNow which marks the function as failed and stops its execution by calling runtime.Goexit and I wasn't sure how to replicate this behavior using Gomega assertions. Is it fine to leave these situations as is?

@kate-osborn
Copy link
Contributor

There are a couple of situations where Fatal/Fatalf is used and I wasn't sure if I should change that to a Gomega assertion. Fatal/Fatalf logs a message then calls FailNow which marks the function as failed and stops its execution by calling runtime.Goexit and I wasn't sure how to replicate this behavior using Gomega assertions. Is it fine to leave these situations as is?

You can change those instances to a gomega assertion. The test will fail and stop executing on the first failed gomega assertion.

@bjee19 bjee19 merged commit a39755d into nginxinc:main Sep 11, 2023
23 checks passed
@bjee19 bjee19 deleted the debt/use-gomega-assertions branch November 20, 2023 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt Short-term pain, long-term benefit
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Use Gomega matcher library for assertions in unit tests
3 participants