-
Notifications
You must be signed in to change notification settings - Fork 373
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
Add unit tests for pkg/agent/controller/traceflow/traceflow_controller.go #4409
Add unit tests for pkg/agent/controller/traceflow/traceflow_controller.go #4409
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4409 +/- ##
=======================================
Coverage 62.00% 62.00%
=======================================
Files 392 392
Lines 56732 56732
=======================================
Hits 35179 35179
Misses 18930 18930
Partials 2623 2623
|
ovsClient *ovsconfigtest.MockOVSBridgeClient | ||
} | ||
|
||
func newFakeController(t *testing.T, initObjects []runtime.Object, networkConfig *config.NetworkConfig, nodeConfig *config.NodeConfig) *fakeController { |
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.
prefer function name and relate to traceflow like newFakeTraceflowController
} | ||
) | ||
|
||
type fakeController struct { |
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.
use specific names for structure like fakeTraceflowController
|
||
var ( | ||
pod1IP = "1.1.1.1" | ||
pod2IP = "2.2.2.2" |
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.
same as above, if string type user pod2IPStr
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.
changed to pod2IPv4, string type can be identified by var type also.
) | ||
|
||
var ( | ||
pod1IP = "1.1.1.1" |
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.
Prefer using specific types like pod1IPv4 for ipv4
5f94001
to
ae289e2
Compare
ae289e2
to
bcebed0
Compare
|
||
tfc.enqueueTraceflow(tc.tf) | ||
|
||
got := tfc.processTraceflowItem() |
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.
processedTraceflow := tfc.processTraceflowItem()
tfc := newFakeTraceflowController(t, []runtime.Object{tf}, nil, nil, nil) | ||
defer tfc.mockController.Finish() | ||
|
||
gotTf, err := tfc.errorTraceflowCRD(tf, reason) |
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.
instead of gotTf, you can use processedTraceflow, or tfReceived, just a suggestion.
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.
few nits
@tnqn Can you please review this PR ? |
e78ab6f
to
ba2585d
Compare
Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
ba2585d
to
0163404
Compare
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.
LGTM
/skip-all |
@Atish-iaf please use more meaningful commit title for future PRs, just "Add unit tests" is not helpful to figure out what the commit is created for among so many commits for unit tests. |
…r.go (antrea-io#4409) Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
Add unit tests
For #4142
Signed-off-by: Kumar Atish atish.iaf@gmail.com