Skip to content

add unit tests for getRuntimeString - #2831

Open
yashrajshuklaaa wants to merge 1 commit into
NVIDIA:mainfrom
yashrajshuklaaa:add-clusterinfo-unit-tests
Open

add unit tests for getRuntimeString#2831
yashrajshuklaaa wants to merge 1 commit into
NVIDIA:mainfrom
yashrajshuklaaa:add-clusterinfo-unit-tests

Conversation

@yashrajshuklaaa

Copy link
Copy Markdown

Description

Adds unit tests for getRuntimeString (docker, containerd, cri-o and error cases). First test file for the clusterinfo package
which had 0% coverage. Now at 5.4%.

Testing

go test ./controllers/clusterinfo/... -v -cover. All 5 subtests pass.

Signed-off-by: Yashraj Shukla <shuklayashraj68@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Added clusterinfo unit tests for getRuntimeString. The table-driven tests cover Docker, containerd, CRI-O, unknown runtime values, and empty runtime values. Valid inputs must return the expected runtime constants. Invalid inputs must return errors.

Merge Risk: ⚪ Minimal · up to d8b1d

This PR only adds unit tests and does not change production behavior. An error-path assertion could be strengthened, but no actionable merge-blocking risk remains.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
controllers/clusterinfo/clusterinfo_test.go-74-76 (1)

74-76: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the returned value for error cases.

The error branch checks only err and returns. If getRuntimeString returns a non-empty runtime with an error, these subtests still pass. Assert that result is empty before returning.

Proposed fix
			if tc.expectError {
				require.Error(t, err)
+				require.Empty(t, result)
				return
			}

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: c075bd47-7526-4e5d-929b-dc62cee21e25

📥 Commits

Reviewing files that changed from the base of the PR and between fa49ea6 and d8b1d0b.

📒 Files selected for processing (1)
  • controllers/clusterinfo/clusterinfo_test.go

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

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.

1 participant