-
Notifications
You must be signed in to change notification settings - Fork 18
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
Remove the BMCClient interface, ginkgo, and gomega #102
Remove the BMCClient interface, ginkgo, and gomega #102
Conversation
Codecov Report
@@ Coverage Diff @@
## main #102 +/- ##
==========================================
+ Coverage 58.85% 62.57% +3.71%
==========================================
Files 4 4
Lines 350 350
==========================================
+ Hits 206 219 +13
+ Misses 107 97 -10
+ Partials 37 34 -3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Some great improvements. Glad to be removing Ginkgo.
controllers/task_controller_test.go
Outdated
for name, tt := range map[string]struct { | ||
configureClientCalls func(expect *mocks.MockBMCClientMockRecorder) | ||
action v1alpha1.Action | ||
func TestTaskReconcile(t *testing.T) { |
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.
The body of the test func has a lot going on. I'm not sure it helps understandability compared to breaking into a few separate table tests. For example, there seems to be different test branches such as the t.timeoutErr
that might help readability if it were a separate top level test.
What's the motivation to bundle all tests into a single table test?
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.
this was mostly a translation of the ginkgo/gomega tests. The idea was to start by removing those libs and then refactoring the tests. I can do the refactor in this PR if you'd like.
type Job struct { | ||
metav1.TypeMeta `json:",inline"` |
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'm weary of removing inline
because every object I've ever seen does it. I'm not 100%, but I think its an option used by Kubernetes client-go json/yaml implementation. Its also documented in examples in the kubebuilder book https://book.kubebuilder.io/cronjob-tutorial/new-api.html.
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.
inline
is not a recognized struct tag in Go. I believe the only reason to keep them is if we have any code generation that depends on it. I ran make generate
and make manifests
and don't think I saw any issues. I could be mistaken though.
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.
Thanks, this has plagued me with the linting and I could never find anything useful about it.
} | ||
|
||
func (r *JobReconciler) reconcile(ctx context.Context, job *bmcv1alpha1.Job, jobPatch client.Patch, logger logr.Logger) (ctrl.Result, error) { | ||
func (r *JobReconciler) doReconcile(ctx context.Context, job *v1alpha1.Job, jobPatch client.Patch) (ctrl.Result, error) { |
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.
Do we need the do
prefix? do
prefixes don't really add anything.
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.
this was a linting issue that came up. I'm open to changing this. I can revert back and add a notlint
or change the name entirely or see about removing the check from the lint config. Thoughts?
secret *corev1.Secret | ||
job *v1alpha1.Job | ||
shouldErr bool | ||
testAll bool |
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.
What are the semantics of testAll
?
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.
testAll
allows this test to do more testing than just if reconciler.Reconcile
was successful. This is an artifact of translating the ginkgo/gomega tests. I will refactor, just depends on if you would like that done in this PR or a follow-up. This PR is fairly large as is.
@Mergifyio queue |
🛑 The pull request has been removed from the queuePull request #102 has been dequeued due to failing checks or checks timeout. You can take a look at In case of a failure due to a flaky test, you should first retrigger the CI. |
This makes it easier to run the linting. And ci will run the exact same linting. Signed-off-by: Jacob Weinstock <[email protected]>
The BMCClient interface was unnecessary and added complexity to testing. bmclib already has the capabilities to specify mock providers. Removing this interface also allowed us to remove ginkgo and gomega. These frameworks were unneeded and overly complex. Also fixed all linting errors. Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Files in the controller package are already namespaced and don't need "_controller" in their name. Signed-off-by: Jacob Weinstock <[email protected]>
The lines were a bit long for reading. Signed-off-by: Jacob Weinstock <[email protected]>
45fdebd
to
4b6b31e
Compare
Signed-off-by: Jacob Weinstock <[email protected]>
@Mergifyio queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 219cdd4 |
Description
Why is this needed
The BMCClient interface was unnecessary and added complexity to testing. bmclib already has the capabilities to specify mock providers. Removing this interface also allowed us to remove ginkgo and gomega. These frameworks were unneeded and overly complex. This PR simplifies tests, increases coverage, and sets us up to build out more tests quickly and simply.
Fixes: #59
How Has This Been Tested?
How are existing users impacted? What migration steps/scripts do we need?
Checklist:
I have: