Skip to content

Conversation

@yuvraj-kolkar17
Copy link

Description

Increases test coverage for pkg/utils/client.go from 79.4% to 100% by adding tests for uncovered error handling scenarios.

New Test Cases

  • TestGetClient_EmptyCredentialName - Tests empty credential name error
  • TestGetClient_InvalidCredentialName - Tests non-existent credential error
  • TestGetClientByCredentialName_DecryptionError - Tests password decryption error

Impact

  • Improves code reliability by testing all error paths
  • Achieves 94% test coverage for client initialization logic
  • No changes to production code, only test additions

@yuvraj-kolkar17
Copy link
Author

PTAL @bupd @Vad1mo

@bupd bupd self-assigned this Dec 6, 2025
@bupd bupd self-requested a review December 6, 2025 14:50
Copy link
Collaborator

@bupd bupd left a comment

Choose a reason for hiding this comment

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

@yuvraj-kolkar17 Thanks for your contribution

https://github.com/goharbor/harbor-cli/actions/runs/19942620956/attempts/2#summary-57184500419

Please fix the above formatting issue and fix lint

Make sure the CI passes and ping me for review. :)

@codecov
Copy link

codecov bot commented Dec 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 6.52%. Comparing base (60ad0bd) to head (d7a3f90).
⚠️ Report is 65 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #579      +/-   ##
=========================================
- Coverage   10.99%   6.52%   -4.47%     
=========================================
  Files         173     260      +87     
  Lines        8671   12842    +4171     
=========================================
- Hits          953     838     -115     
- Misses       7612   11902    +4290     
+ Partials      106     102       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yuvraj-kolkar17
Copy link
Author

@yuvraj-kolkar17 Thanks for your contribution

https://github.com/goharbor/harbor-cli/actions/runs/19942620956/attempts/2#summary-57184500419

Please fix the above formatting issue and fix lint

Make sure the CI passes and ping me for review. :)

Thanks @bupd for the feedback
I will correct the changes and update the PR shortly.
Will ping you once done

Signed-off-by: Yuvraj Kolkar <[email protected]>
@yuvraj-kolkar17
Copy link
Author

hi @bupd , I’ve made the requested changes and updated the PR
kindly review it when you get a moment.
Thanks

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances test coverage for pkg/utils/client.go by adding three new test cases that exercise previously untested error handling paths in the client initialization logic. The tests target specific error scenarios: empty credential names, invalid credential names, and password decryption failures.

  • Adds comprehensive error path testing for GetClient() and GetClientByCredentialName() functions
  • Increases test coverage from 79.4% to 94.1% through targeted error scenario tests
  • Introduces sync package import to support singleton reset patterns in tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@bupd bupd left a comment

Choose a reason for hiding this comment

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

Please run gofmt -s -w . to fix the lint issues

Thanks

Signed-off-by: Yuvraj Kolkar <[email protected]>
@yuvraj-kolkar17
Copy link
Author

PTAL @bupd

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.

2 participants