-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixed bug in flagutil package and added tests #15046
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15046 +/- ##
==========================================
+ Coverage 47.49% 47.54% +0.04%
==========================================
Files 1149 1149
Lines 239387 239325 -62
==========================================
+ Hits 113692 113778 +86
+ Misses 117102 116959 -143
+ Partials 8593 8588 -5 ☔ View full report in Codecov by Sentry. |
ef0a23d
to
1ec7f05
Compare
@systay could you please go through this PR during your spare time? Thanks :) |
go/flagutil/enum_test.go
Outdated
) | ||
|
||
func TestNewStringEnumCaseSensitive(t *testing.T) { | ||
enum := NewStringEnum("fruits enum", "Mango", []string{"apple", "Mango"}) |
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.
Why not fold these functions in as test cases in the TestStringEnum
test function?
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.
Done, thanks for the suggestion.
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(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.
You need to capture the tt
variable within the loop. See this for an example/explainer
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.
Understood, done.
choices: choiceMap, | ||
choiceNames: choiceNames, | ||
choiceMapper: choiceMapper, | ||
caseInsensitive: caseInsensitive, |
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!
Signed-off-by: VaibhavMalik4187 <[email protected]>
1ec7f05
to
079d302
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!
Description
Bug: the
caseInsensitive
variables was not being used inStringEnum
initialization.Fix: Added code to initialize the
caseInsensitive
variable when theStringEnum
instance is created.Added unit tests to increase the code coverage of the
flagutil
package.Related Issue(s)
Partially addresses: #14931
Checklist