Skip to content

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 force-pushed the debt/use-gomega-assertions branch from 89c43a9 to c3905f6 Compare September 11, 2023 19:44
@bjee19 bjee19 requested a review from sjberman September 11, 2023 20:37
@bjee19 bjee19 merged commit a39755d into nginx:main Sep 11, 2023
@bjee19 bjee19 deleted the debt/use-gomega-assertions branch November 20, 2023 18:41
miledxz added a commit to miledxz/nginx-gateway-fabric that referenced this pull request Jan 14, 2025
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, replaced deprecated
NewGomegaWithT with NewWithT, and added sub-tests to existing tests.
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

None yet

Development

Successfully merging this pull request may close these issues.

Use Gomega matcher library for assertions in unit tests

3 participants