-
Notifications
You must be signed in to change notification settings - Fork 60
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 controllers test setup & teardown for reusability between Ginkgo and standard Go tests #473
Refactor controllers test setup & teardown for reusability between Ginkgo and standard Go tests #473
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #473 +/- ##
==========================================
+ Coverage 83.41% 83.64% +0.23%
==========================================
Files 23 23
Lines 862 862
==========================================
+ Hits 719 721 +2
+ Misses 97 96 -1
+ Partials 46 45 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
4fbab63
to
8fe25b4
Compare
This will enable both Ginkgo and standard Go tests to use the same setup & teardown. Signed-off-by: Mikalai Radchuk <[email protected]>
8fe25b4
to
0ae42f3
Compare
cl client.Client | ||
sch *runtime.Scheme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed cfg
and testEnv
from here. They were defined on the package level so that both BeforeSuite
and AfterSuite
could access them. Now that we do setup and teardown in single TestMain
function - they can be function scoped.
var operators operatorsv1alpha1.OperatorList | ||
var bundleDeployments rukpakv1alpha1.BundleDeploymentList | ||
|
||
Expect(cl.List(context.Background(), &operators)).To(Succeed()) | ||
Expect(cl.List(context.Background(), &bundleDeployments)).To(Succeed()) | ||
|
||
Expect(namesFromList(&operators)).To(BeEmpty(), "operators left in the cluster") | ||
Expect(namesFromList(&bundleDeployments)).To(BeEmpty(), "bundle deployments left in the cluster") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I droped this bit. I do not see much value in failing after tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was to ensure everything is cleaned up before stopping the running envtest process, but if envtest exits just fine without this cleanup I think its OK to remove
`check-cluster` is already a dependency of the `install` targt, which is a dependency of `e2e`. It does not need to be a dependency of `test-e2e` which _just_ runs the tests without any setup. Signed-off-by: Todd Short <[email protected]>
Description
This will enable both Ginkgo and standard Go tests to use the same setup & teardown.
This will help to get rid of some of the setup boilerplate in #469.
Reviewer Checklist