Skip to content

[feature-1707]: Increase unit test coverage to 90%#896

Merged
atye merged 23 commits intomainfrom
pub/increase-ut-coverage
Feb 13, 2025
Merged

[feature-1707]: Increase unit test coverage to 90%#896
atye merged 23 commits intomainfrom
pub/increase-ut-coverage

Conversation

@atye
Copy link
Copy Markdown
Contributor

@atye atye commented Feb 11, 2025

Description

Increase unit test coverage to 90%.

GitHub Issues

List the GitHub issues impacted by this PR:

GitHub Issue #
https://github.com/dell/csm/issues/1707

Checklist:

  • I have performed a self-review of my own code to ensure there are no formatting, vetting, linting, or security issues
  • I have verified that new and existing unit tests pass locally with my changes
  • I have not allowed coverage numbers to degenerate
  • I have maintained at least 90% code coverage
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have maintained backward compatibility
  • I have executed the relevant end-to-end test scenarios

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

Unit tests. Installed Operator verify that it runs.

@@ -1,4 +1,4 @@
// Copyright © 2022 - 2023 Dell Inc. or its subsidiaries. All Rights Reserved.
// Copyright © 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 2022-2025. You don't lose copyright for previous years.

donatwork
donatwork previously approved these changes Feb 13, 2025
Comment on lines +1 to +2
/*
Copyright © 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Don said, this should be 2021-2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}() // #nosec G20
}

gitdesc := chkErr(doExec("git", "describe", "--long", "--dirty"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line may give you trouble because it creates inconsistent UT-- the code executes on the current commit status, I had to extract it out in my semver https://github.com/dell/csi-powerflex/pull/420/files#diff-a656f5ce872be362bd5d216186de6396334c2c2c77830591f5e7dec50a853f9fR67-R68

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines +28 to +33
tests := []struct {
name string
format string
outputFile string
expectEmptyFile bool
readFileFunc func(file string) ([]byte, error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're hitting coverage, it's fine, but I needed to add some more control to this so that I could inject a desired "git describe" output in csi-powerflex: https://github.com/dell/csi-powerflex/pull/420/files#diff-050199f17155af589ff5135cf4ee18854937db044813677c6e90805f076cb421R47-R53

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

main.go Outdated
@@ -1,4 +1,4 @@
// Copyright © 2021 - 2023 Dell Inc. or its subsidiaries. All Rights Reserved.
// Copyright © 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright years.

Also, it isn't fun, but you're probably going to need to do some smoke tests since main.go was changed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I built the Operator image and installed it successfully.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@atye atye dismissed stale reviews from ChristianAtDell and donatwork via ff03d18 February 13, 2025 18:42
donatwork
donatwork previously approved these changes Feb 13, 2025
alikdell
alikdell previously approved these changes Feb 13, 2025
@atye atye dismissed stale reviews from alikdell and donatwork via cae2c24 February 13, 2025 18:51
@atye atye merged commit 6bd4f9c into main Feb 13, 2025
@atye atye deleted the pub/increase-ut-coverage branch February 13, 2025 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants