Skip to content

Conversation

@AlbinJohns-wk
Copy link
Owner

Change description

Project tracking

Do any added TODOs have an issue in the backlog?

Did you add unit tests? Why not?

Does this code need functional testing?

Is a code review walkthrough needed? why or why not?

Should additional test coverage be executed in addition to pre-merge?

Does this code need a note in the changelog?

Does this code require documentation changes?

Additional Information

Add three new utility functions:
- ValidateProtocol: validate protocol types
- CalculateStorageSize: convert size strings to bytes
- FormatDuration: format durations as human-readable strings

Test the auto-generate unit tests workflow with fixed YAML.
@AlbinJohns-wk
Copy link
Owner Author

@copilot check current coverage and improve the coverage to above 90 for newly added functions.

Copy link

Copilot AI commented Dec 12, 2025

@AlbinJohns-wk I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits December 12, 2025 13:37
…unctions

- Added TestCalculateStorageSize with 17 test cases covering:
  - Valid sizes with binary units (Gi, Mi, Ti, Ki)
  - Valid sizes with decimal units (G, M, T, k)
  - Various edge cases (zero, single byte, etc.)
  - Error cases (empty string, invalid formats, negative values)
- Added TestFormatDuration with 26 test cases covering:
  - Milliseconds formatting
  - Seconds only formatting
  - Minutes only formatting
  - Minutes and seconds formatting
  - Hours only formatting
  - Hours and minutes formatting
  - Large durations
- Achieved >90% coverage for both functions:
  - CalculateStorageSize: 90.9%
  - FormatDuration: 100.0%
- Overall package coverage increased from 74.8% to 96.4%

Co-authored-by: AlbinJohns-wk <220135713+AlbinJohns-wk@users.noreply.github.com>
The coverage files were temporary and shouldn't be tracked. Removed the gitignore entry as requested.

Co-authored-by: AlbinJohns-wk <220135713+AlbinJohns-wk@users.noreply.github.com>
Add test coverage for CalculateStorageSize and FormatDuration utility functions
@github-actions
Copy link

Code Coverage

Package Line Rate
github.com/netapp/trident/acp 56%
github.com/netapp/trident/acp/rest 85%
github.com/netapp/trident/chwrap 0%
github.com/netapp/trident/cli/api 0%
github.com/netapp/trident/cli/cmd 70%
github.com/netapp/trident/cli/k8s_client 79%
github.com/netapp/trident/cli 0%
github.com/netapp/trident/config 95%
github.com/netapp/trident/core/cache 100%
github.com/netapp/trident/core 72%
github.com/netapp/trident/core/concurrent_cache 86%
github.com/netapp/trident/frontend/common 95%
github.com/netapp/trident/frontend/crd/controller 67%
github.com/netapp/trident/frontend/crd/controller/indexers 100%
github.com/netapp/trident/frontend/crd/controller/indexers/vaindexer 100%
github.com/netapp/trident/frontend/csi/controller_api 92%
github.com/netapp/trident/frontend/csi/controller_helpers/kubernetes 72%
github.com/netapp/trident/frontend/csi/controller_helpers/plain 90%
github.com/netapp/trident/frontend/csi 82%
github.com/netapp/trident/frontend/csi/node_helpers/kubernetes 88%
github.com/netapp/trident/frontend/csi/node_helpers/plain 94%
github.com/netapp/trident/frontend/docker 78%
github.com/netapp/trident/frontend/metrics 71%
github.com/netapp/trident/frontend/rest 88%
github.com/netapp/trident/internal/chwrap 0%
github.com/netapp/trident/internal/crypto 31%
github.com/netapp/trident/internal/fiji 83%
github.com/netapp/trident/internal/fiji/models 74%
github.com/netapp/trident/internal/fiji/models/handlers 76%
github.com/netapp/trident/internal/fiji/rest 72%
github.com/netapp/trident/internal/fiji/store 96%
github.com/netapp/trident/internal/nodeprep/execution 100%
github.com/netapp/trident/internal/nodeprep/instruction 100%
github.com/netapp/trident/internal/nodeprep/mpathconfig 90%
github.com/netapp/trident/internal/nodeprep/nodeinfo 92%
github.com/netapp/trident/internal/nodeprep 100%
github.com/netapp/trident/internal/nodeprep/packagemanager/apt 91%
github.com/netapp/trident/internal/nodeprep/packagemanager/yum 100%
github.com/netapp/trident/internal/nodeprep/protocol 100%
github.com/netapp/trident/internal/nodeprep/step 100%
github.com/netapp/trident/internal/nodeprep/systemmanager/debian 100%
github.com/netapp/trident/internal/nodeprep/systemmanager/rhel 100%
github.com/netapp/trident/internal/nodeprep/systemmanager/systemctl 100%
github.com/netapp/trident/internal/syswrap 0%
github.com/netapp/trident/logging 88%
github.com/netapp/trident 10%
github.com/netapp/trident/operator/clients 71%
github.com/netapp/trident/operator/config 100%
github.com/netapp/trident/operator/controllers/configurator/clients 77%
github.com/netapp/trident/operator/controllers/configurator 73%
github.com/netapp/trident/operator/controllers/configurator/storage_drivers 74%
github.com/netapp/trident/operator/controllers/orchestrator 31%
github.com/netapp/trident/operator/controllers/orchestrator/installer 78%
github.com/netapp/trident/operator/crd/apis/netapp/v1 3%
github.com/netapp/trident/operator/frontend/rest 98%
github.com/netapp/trident/operator 4%
github.com/netapp/trident/persistent_store/crd/apis/netapp/v1 18%
github.com/netapp/trident/persistent_store 63%
github.com/netapp/trident/pkg/capacity 94%
github.com/netapp/trident/pkg/collection 87%
github.com/netapp/trident/pkg/convert 63%
github.com/netapp/trident/pkg/locks 44%
github.com/netapp/trident/pkg/maths 74%
github.com/netapp/trident/pkg/network 100%
github.com/netapp/trident/pkg/yaml 43%
github.com/netapp/trident/storage 59%
github.com/netapp/trident/storage/factory 91%
github.com/netapp/trident/storage_attribute 98%
github.com/netapp/trident/storage_class 93%
github.com/netapp/trident/storage_drivers/azure/api 37%
github.com/netapp/trident/storage_drivers/azure 98%
github.com/netapp/trident/storage_drivers 84%
github.com/netapp/trident/storage_drivers/gcp/api 40%
github.com/netapp/trident/storage_drivers/gcp 97%
github.com/netapp/trident/storage_drivers/ontap/api 72%
github.com/netapp/trident/storage_drivers/ontap 92%
github.com/netapp/trident/storage_drivers/ontap/awsapi 70%
github.com/netapp/trident/storage_drivers/solidfire/api 78%
github.com/netapp/trident/storage_drivers/solidfire 33%
github.com/netapp/trident/testing 60%
github.com/netapp/trident/utils/devices 88%
github.com/netapp/trident/utils/devices/luks 80%
github.com/netapp/trident/utils/durations 100%
github.com/netapp/trident/utils/errors 100%
github.com/netapp/trident/utils/exec 87%
github.com/netapp/trident/utils/fcp 74%
github.com/netapp/trident/utils/filesystem 84%
github.com/netapp/trident/utils/iscsi 72%
github.com/netapp/trident/utils/limiter 95%
github.com/netapp/trident/utils/lsblk 89%
github.com/netapp/trident/utils/models 91%
github.com/netapp/trident/utils/mount/filepathwrapper 100%
github.com/netapp/trident/utils/mount 95%
github.com/netapp/trident/utils/mount/oswrapper 57%
github.com/netapp/trident/utils/nfs 100%
github.com/netapp/trident/utils/nvme 85%
github.com/netapp/trident/utils/osutils 83%
github.com/netapp/trident/utils/version 59%
Summary 75% (77251 / 103440)

Minimum allowed line rate is 69%

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