-
Notifications
You must be signed in to change notification settings - Fork 504
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
Added Unit test coverage for Kustomize V3 Iac-provider #399
Conversation
d9118f0
to
1e93ef5
Compare
Codecov Report
@@ Coverage Diff @@
## master #399 +/- ##
==========================================
+ Coverage 63.55% 66.21% +2.66%
==========================================
Files 85 85
Lines 1904 1915 +11
==========================================
+ Hits 1210 1268 +58
+ Misses 591 535 -56
- Partials 103 112 +9
|
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 believe, there is scope for adding test cases for testing various error conditions.
For eg:
- In
LoadIacDir
, a test case can be added to check the error whenkustomization.yaml
is not present in the user provided directory - Similarly, a test case for checking the error conditions when more than 1
kustomization.yaml
s are present. - Another, test case is possible for an empty
kustomization.yaml
In this way some test cases can be added for LoadKustomize
method as well
Thanks for reminding. Missed that case.
you can't have more than one file with the same name in a directory (as per OS constraints). So that part is taken care of Realised later : There can be kustomization.yaml and kustomization.yml file in the same directory!
Yep |
1e93ef5
to
08b323f
Compare
08b323f
to
386a4d4
Compare
wantErr error | ||
}{ | ||
{ | ||
name: "load iac file is not supported for helm", |
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.
"for kustomize"
zap.S().Error("error while searching for iac files", zap.String("root dir", absRootDir), zap.Error(err)) | ||
return allResourcesConfig, err | ||
} | ||
|
||
if len(files) == 0 { | ||
err = errors.New("could not find a kustomization.yaml/yml file in the directory") | ||
err = errorKustomizeNotFound(errors.New("could not find a kustomization.yaml/yml file in the directory")) |
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.
Recommend to move the error definitions into a variable that can be referenced easily by unit tests
zap.S().Error("error while searching for iac files", zap.String("root dir", absRootDir), zap.Error(err)) | ||
return allResourcesConfig, err | ||
} | ||
|
||
if len(files) > 1 { | ||
err = errors.New("a directory cannot have more than 1 kustomization.yaml/yml file") | ||
err = errorMultipleKustomizeFile(errors.New("a directory cannot have more than 1 kustomization.yaml/yml file")) |
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--Recommend to move the error definitions into a variable that can be referenced easily by unit tests
err = fmt.Errorf("unable to read any kustomization file in the directory : %v", err) | ||
zap.S().Error("error while searching for iac files", zap.String("root dir", absRootDir), zap.Error(err)) | ||
if err != nil { | ||
err = fmt.Errorf("unable to read the kustomization file in the directory : %v", 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.
Recommend to move the error definitions into a variable that can be referenced easily by unit tests
386a4d4
to
1f296e6
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Fix #379