-
Notifications
You must be signed in to change notification settings - Fork 54
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
[WiP] OSD-20504: Add test case for config's get subcommand #404
base: main
Are you sure you want to change the base?
Conversation
@TheUndeadKing: This pull request references OSD-20504 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set. In response to this:
Instructions 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 openshift-eng/jira-lifecycle-plugin repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: TheUndeadKing The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I tried to write test case[load value for backplane url & doesn't load any value for backplane url] for get function. In both test case the error return as nil.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #404 +/- ##
==========================================
+ Coverage 45.66% 45.81% +0.14%
==========================================
Files 78 78
Lines 6160 6160
==========================================
+ Hits 2813 2822 +9
+ Misses 2997 2987 -10
- Partials 350 351 +1 |
It("Get backplane url return value", func() { | ||
mockOcmInterface.EXPECT().GetOCMEnvironment().Return(ocmEnv, nil).AnyTimes() | ||
err := getConfig(cmd, []string{"url"}) | ||
fmt.Println("Return value: ", err) |
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.
We don't need a return value to be printed in test.
It("Get backplane url return nil", func() { | ||
mockOcmInterface.EXPECT().GetOCMEnvironment().Return(ocmEnvNil, nil).AnyTimes() | ||
err := getConfig(cmd, []string{"url"}) | ||
fmt.Println("Return nil: ", err) |
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.
We don't need a return value to be printed in test.
|
||
ocmEnvNil, _ := cmv1.NewEnvironment().BackplaneURL("").Build() | ||
|
||
cmd := &cobra.Command{Use: "get"} |
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 cmd
variable could be initialized within the BeforeEach block to ensure that each test case starts with a fresh instance which could prevent potential side effects from previous 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.
If i declare cmd inside before each block, it's not been exported as global variable. i.e, can't use it in the test case
@TheUndeadKing: all tests passed! Full PR test history. Your PR dashboard. Instructions 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-sigs/prow repository. I understand the commands that are listed here. |
@TheUndeadKing - Are you still working on this PR? |
What type of PR is this?
unit-test
What this PR does / Why we need it?
Adding test case for config's get subcommand