test: add unit tests for nvinternal info, mig, and watch packages#1893
Conversation
|
Welcome @pmady! It looks like this is your first PR to Project-HAMi/HAMi 🎉 |
There was a problem hiding this comment.
Code Review
This pull request introduces unit tests for versioning, MIG capability detection, and file/signal watchers. The review feedback highlights that the MIG capability test is environment-dependent and suggests refactoring the underlying function to support filesystem mocking. Additionally, it is recommended to replace hardcoded temporary paths in the watcher tests with t.TempDir() to ensure better portability across different environments.
Signed-off-by: pmady <pavan4devops@gmail.com>
5190c7f to
a8d5267
Compare
Signed-off-by: pmady <pavan4devops@gmail.com>
Signed-off-by: pmady <pavan4devops@gmail.com>
Signed-off-by: pmady <pavan4devops@gmail.com>
|
fixed all three — copyright year updated to 2026, switched to t.TempDir() for the nonexistent path, and added a t.Skip guard on the MIG test so it wont fail on machines with nvidia-caps present |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: archlitchi, pmady The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Adds unit tests for three packages under
pkg/device-plugin/nvidiadevice/nvinternal/that had zero test coverage:info/version_test.go (6 tests)
GetVersionwith custom and default valuesGetVersionPartswith and without git commitGetVersionStringbasic and with extra argsmig/mig_test.go (1 test)
GetMigCapabilityDevicePathsreturns nil on non-MIG machines (covers theos.IsNotExistearly-return path)watch/watchers_test.go (4 tests)
Fileswith valid path, nonexistent path, and empty inputSignalschannel creationAll tests pass locally. No production code changes.
Ref #569