Skip to content

test: add unit tests for nvinternal info, mig, and watch packages#1893

Merged
hami-robot[bot] merged 4 commits into
Project-HAMi:masterfrom
pmady:test/add-info-version-tests
May 26, 2026
Merged

test: add unit tests for nvinternal info, mig, and watch packages#1893
hami-robot[bot] merged 4 commits into
Project-HAMi:masterfrom
pmady:test/add-info-version-tests

Conversation

@pmady

@pmady pmady commented May 20, 2026

Copy link
Copy Markdown
Contributor

Adds unit tests for three packages under pkg/device-plugin/nvidiadevice/nvinternal/ that had zero test coverage:

info/version_test.go (6 tests)

  • GetVersion with custom and default values
  • GetVersionParts with and without git commit
  • GetVersionString basic and with extra args

mig/mig_test.go (1 test)

  • GetMigCapabilityDevicePaths returns nil on non-MIG machines (covers the os.IsNotExist early-return path)

watch/watchers_test.go (4 tests)

  • Files with valid path, nonexistent path, and empty input
  • Signals channel creation

All tests pass locally. No production code changes.

Ref #569

@hami-robot

hami-robot Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Welcome @pmady! It looks like this is your first PR to Project-HAMi/HAMi 🎉

@hami-robot hami-robot Bot added the size/L label May 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

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.

Comment thread pkg/device-plugin/nvidiadevice/nvinternal/mig/mig_test.go
Comment thread pkg/device-plugin/nvidiadevice/nvinternal/watch/watchers_test.go Outdated
Signed-off-by: pmady <pavan4devops@gmail.com>
@pmady
pmady force-pushed the test/add-info-version-tests branch from 5190c7f to a8d5267 Compare May 20, 2026 19:34
Comment thread pkg/device-plugin/nvidiadevice/nvinternal/info/version_test.go Outdated
pmady added 3 commits May 21, 2026 17:09
Signed-off-by: pmady <pavan4devops@gmail.com>
Signed-off-by: pmady <pavan4devops@gmail.com>
Signed-off-by: pmady <pavan4devops@gmail.com>
@pmady

pmady commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

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

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 58.15% <ø> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 14 files with indirect coverage changes

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

@archlitchi archlitchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@hami-robot

hami-robot Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot Bot added the approved label May 26, 2026
@hami-robot
hami-robot Bot merged commit c7efc9a into Project-HAMi:master May 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants