Unit testing Coverage report#376
Conversation
588aeaa to
2cffa73
Compare
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
add coverage threshold verification to dagger function integrate coverage check into GitHub Actions pipeline ensure proper syntax in shell script for accurate comparison set initial coverage threshold at 80% for CI enforcement Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…lso in memeory config can be updated Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
d2f85c5 to
2a44191
Compare
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…onfig cmd test from to context_test pkg Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
|
Now this PR is ready for review. I've updated the description with all the details about the test coverage implementation and undrafted it. @Vad1mo, I'd appreciate your feedback, especially on the "Decisions Required Before Merging" section. |
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This draft PR establishes a framework for unit testing and coverage reporting, reorganizes existing tests into focused packages, and centralizes shared test utilities.
- Integrate Dagger-based test coverage and reporting tasks into CI
- Reorganize tests under
utils_testandroot_testpackages - Introduce a shared
test/helperpackage and newSetCurrentHarborConfigAPI
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/utils/helper_test.go | Add end-to-end unit tests for utility functions |
| pkg/utils/encryption_test.go | Rename test package to utils_test |
| pkg/utils/config_test.go | Refactor config tests to use shared helpers |
| pkg/utils/config.go | Add SetCurrentHarborConfig method |
| pkg/utils/client_test.go | Add tests for client initialization |
| pkg/utils/client.go | Rename client globals and improve error logging |
| pkg/api/project_handler.go | Add error handling for ParseProjectRepo in deletion |
| cmd/harbor/root/repository/view.go | Handle parse errors in RepoViewCmd |
| cmd/harbor/root/repository/delete.go | Handle parse errors and early return in RepoDeleteCmd |
| cmd/harbor/root/login_test.go | Refactor login tests to use shared helpers |
| cmd/harbor/root/context/config_cmd_test.go | Refactor context commands tests using helpers |
| cmd/harbor/root/artifact/view.go | Add parse error check in ViewArtifactCommand |
| cmd/harbor/root/artifact/tags.go | Add parse error check in tag creation/list/delete cmds |
| cmd/harbor/root/artifact/scan.go | Add parse error check in scan start/stop commands |
| cmd/harbor/root/artifact/list.go | Validate parse results in ListArtifactsCmd |
| cmd/harbor/root/artifact/delete.go | Add parse error check in DeleteArtifactCommand |
| README.md | Add a personal Codecov badge (needs replacement) |
| .github/workflows/default.yaml | Add Dagger coverage and Codecov steps |
| .dagger/main.go | Add TestCoverage and TestCoverageReport steps |
| .dagger/README.md | Document new coverage-report commands |
Comments suppressed due to low confidence (2)
pkg/api/project_handler.go:119
- The variable
projectNameis not defined in this scope. It should use the incomingprojectNameOrIDor introduce a localprojectNamebefore callingRepoDelete.
err = RepoDelete(projectName, repoName, useProjectID)
cmd/harbor/root/artifact/list.go:56
- This callback is defined with
Run:(no return value). Returning anerrorhere will not compile. UseRunE:or handle the error viacmd.PrintErrandos.Exit(1).
return fmt.Errorf("failed to parse project/repo: %v", err)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com>
* Resolve merge conflicts Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added codecov badge for testing Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added codecov badge for testing Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added helpers package to context test after upstream rebase Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added changes to satisfy linter Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added dagger coverage steps to pipeline Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * ci(coverage): implement test coverage threshold check add coverage threshold verification to dagger function integrate coverage check into GitHub Actions pipeline ensure proper syntax in shell script for accurate comparison set initial coverage threshold at 80% for CI enforcement Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Fix failing test Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Cleanup client testing; added setconfig function to utils such that also in memeory config can be updated Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added changes to satisfy linter Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added test coverage entries to dagger readme Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added test coverage entries to dagger readme Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Test code cov token for upload Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Fix: wrong helper import in cmd test Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Update: test coverage report export Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Changed pipeline for test summary Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Changed pipeline for test summary Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Changed pipeline for test summary Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Adjusted dagger function for test report; added step summary; moved config cmd test from to context_test pkg Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added note about target coverage Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Readded coverage step for codecov upload Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Update cmd/harbor/root/repository/delete.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> * Update .dagger/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> * Update pkg/utils/client.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> --------- Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Resolve merge conflicts Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added codecov badge for testing Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added codecov badge for testing Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added helpers package to context test after upstream rebase Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added changes to satisfy linter Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added dagger coverage steps to pipeline Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * ci(coverage): implement test coverage threshold check add coverage threshold verification to dagger function integrate coverage check into GitHub Actions pipeline ensure proper syntax in shell script for accurate comparison set initial coverage threshold at 80% for CI enforcement Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Fix failing test Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Cleanup client testing; added setconfig function to utils such that also in memeory config can be updated Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added changes to satisfy linter Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added test coverage entries to dagger readme Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added test coverage entries to dagger readme Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Test code cov token for upload Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Fix: wrong helper import in cmd test Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Update: test coverage report export Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Changed pipeline for test summary Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Changed pipeline for test summary Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Changed pipeline for test summary Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Adjusted dagger function for test report; added step summary; moved config cmd test from to context_test pkg Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added note about target coverage Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Readded coverage step for codecov upload Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Update cmd/harbor/root/repository/delete.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> * Update .dagger/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> * Update pkg/utils/client.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> --------- Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> Signed-off-by: Patrick Eschenbach <45457307+qcserestipy@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Draft PR: Enhancing Unit Testing and Code Coverage Reporting
This PR is a work-in-progress aimed at discussing and refining our approach to unit testing and code coverage in the project. Below is an overview of the key changes introduced:
Unit Test Coverage with Dagger:
I have added Dagger functions that generate a unit test coverage report for the repository. This setup allows us to execute tests in a containerized environment and obtain comprehensive coverage metrics.
Reorganized Test Structure:
Our current tests were more aligned with unit testing rather than end-to-end (E2E) testing. To improve clarity and maintainability, I have moved these tests into distinct packages within the
cmdandpkgdirectories. This separation will help us better manage and expand our test suites.Shared Testing Helper Package:
A new testing helper package has been created to consolidate functionality shared by all tests. This change reduces duplication and makes it easier to write and maintain future tests.
Since additional unit tests are expected in forthcoming PRs, this PR serves as a preliminary framework. I would also like to open a discussion on how best to integrate unit testing and reporting into our CI/CD pipeline. For example, we could eventually add a coverage report badge to the project to provide ongoing visibility into our code quality.
I look forward to your feedback and suggestions.
Decisions Required Before Merging
CODECOV_TOKEN: Verify theCODECOV_TOKENsecret is properly configured in the repository settingsScreenshots
Quick View
Extended view
Codecov commit view