Skip to content

test(unikernels): add unit tests for New, subnetMaskToCIDR, and createFile - #1215

Open
AbdullahZulfiqar2005 wants to merge 1 commit into
urunc-dev:mainfrom
AbdullahZulfiqar2005:test/unikernels-factory-and-utils
Open

AbdullahZulfiqar2005 wants to merge 1 commit into
urunc-dev:mainfrom
AbdullahZulfiqar2005:test/unikernels-factory-and-utils

Conversation

@AbdullahZulfiqar2005

Copy link
Copy Markdown

Description

Adds table-driven unit tests for previously uncovered functions in pkg/unikontainers/unikernels:

unikernel_test.go (New): Verifies concrete types returned for all 7 supported unikernels (rumprun, unikraft, mirage, mewz, linux, hermit, freebsd) and verifies ErrNotSupportedUnikernel for empty, unknown, and mismatched-case inputs (0.0% → 100.0% coverage).
utils_test.go (subnetMaskToCIDR, createFile): Covers standard and non-octet subnet masks (/0, /8, /16, /20, /24, /32), malformed/out-of-range mask errors (81.8% → 100.0% coverage), plus file creation, overwrite, and missing parent directory errors using t.TempDir() (0.0% → 87.5% coverage).

Overall pkg/unikontainers/unikernels statement coverage increases from 32.7% to 38.6%.

Related issues

How was this tested?

Ran unit tests with race detection, coverage, formatting, and vet locally:

gofmt -l pkg/unikontainers/unikernels/unikernel_test.go pkg/unikontainers/unikernels/utils_test.go
go vet ./pkg/unikontainers/unikernels/...
go test -v -race -coverprofile=/tmp/urunc_cov.out ./pkg/unikontainers/unikernels/...
go tool cover -func=/tmp/urunc_cov.out

All tests pass with zero data races.

LLM usage

Assisted by gemini 4 neon for drafting the initial table-driven test cases and reviewing coverage; all test cases were reviewed, formatted, and verified locally.

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

…eFile

Signed-off-by: Abdullah Zulfiqar <abdullahzulfiqar580@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 17:09
@netlify

netlify Bot commented Nov 19, 2026

Copy link
Copy Markdown

👷 Deploy request for urunc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 2499e56

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

Add more unit tests

2 participants