test(dataflowaffinity): migrate to Ginkgo/Gomega#5685
test(dataflowaffinity): migrate to Ginkgo/Gomega#5685hxrshxz wants to merge 2 commits intofluid-cloudnative:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @hxrshxz. Thanks for your PR. I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the testing quality and coverage for the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Signed-off-by: Harsh <harshmastic@gmail.com>
320340a to
4fe7d5b
Compare
There was a problem hiding this comment.
Code Review
The pull request refactors the dataflowaffinity_controller_test.go file from the standard testing package to use the Ginkgo/Gomega testing framework, introducing a new suite_test.go file for test setup. This includes comprehensive test cases for the DataOpJobReconciler's Reconcile method and the injectPodNodeLabelsToJob helper function. A review comment suggests replacing context.TODO() with context.Background() in the tests for improved clarity and adherence to best practices.
| It("returns an error (not-found propagates)", func() { | ||
| c := fake.NewFakeClientWithScheme(testScheme) | ||
| f := &DataOpJobReconciler{Client: c, Log: fake.NullLogger()} | ||
| _, err := f.Reconcile(context.TODO(), reconcile.Request{ |
There was a problem hiding this comment.
It is a better practice to use context.Background() instead of context.TODO() in tests when a background, non-cancellable context is needed. context.TODO() is intended as a temporary placeholder. Please replace all instances of context.TODO() with context.Background() in this file for consistency and clarity.
| _, err := f.Reconcile(context.TODO(), reconcile.Request{ | |
| _, err := f.Reconcile(context.Background(), reconcile.Request{ |
There was a problem hiding this comment.
Pull request overview
This PR migrates the unit tests in pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/ from Go's standard testing package table-driven style to Ginkgo v2/Gomega BDD-style, adds a suite bootstrap file, and expands test coverage from 39% to 81.4% by adding specs for Reconcile, ControllerName, ManagedResource, and NewDataOpJobReconciler.
Changes:
- Added
suite_test.goto bootstrap the Ginkgo test suite for thedataflowaffinitypackage. - Migrated existing
injectPodNodeLabelsToJobtests from table-driventesting.Tstyle to GinkgoDescribe/Context/Itblocks. - Added new test specs covering
ControllerName,ManagedResource,NewDataOpJobReconciler, and fourReconcilescenarios (not-found, cronjob-skip, annotation injection, complete-job with node label injection).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/suite_test.go |
New Ginkgo suite bootstrap file for the dataflowaffinity package |
pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/dataflowaffinity_controller_test.go |
Migrated existing tests to Ginkgo/Gomega and added new test specs for broader coverage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5685 +/- ##
=======================================
Coverage 61.21% 61.21%
=======================================
Files 444 444
Lines 30540 30540
=======================================
Hits 18694 18694
Misses 10306 10306
Partials 1540 1540 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Harsh <harshmastic@gmail.com>
0ea9958 to
46458b8
Compare
|



Ⅰ. Describe what this PR does
Migrates unit tests in
pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/from the standardtestingpackage to Ginkgo v2/Gomega, adds a package-level suite bootstrap (suite_test.go), and expands test coverage from 39% to 81.4% by adding specs forReconcile,ControllerName,ManagedResource, andNewDataOpJobReconciler.Ⅱ. Does this pull request fix one issue?
#5676
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
ControllerName— asserts the constant string is returnedManagedResource— asserts a*batchv1.Jobis returnedNewDataOpJobReconciler— asserts the constructor wires client correctlyReconcile(4 cases): job not found (propagates error), job with cronjob label (skipped/no-requeue), valid fluid job without affinity annotation (annotation injected), complete job with succeeded pod (node labels injected)injectPodNodeLabelsToJob(2 cases): succeeded pod injects annotations; failed-only pod returns errorⅣ. Describe how to verify it
Ⅴ. Special notes for reviews
N/A