Skip to content

test(ctl/dump): add unit tests for kmeshctl dump table rendering - #1931

Open
magic-peach wants to merge 1 commit into
kmesh-net:mainfrom
magic-peach:test-kmeshctl-dump-unit-tests
Open

magic-peach wants to merge 1 commit into
kmesh-net:mainfrom
magic-peach:test-kmeshctl-dump-unit-tests

Conversation

@magic-peach

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

ctl/dump has no unit test coverage for its output formatting: uint32ToIPStr,
printDualEngineTable, and printKernelNativeTable are pure functions that
parse a JSON dump and render it as a table, but a regression there ships
undetected until someone notices kmeshctl dump output looks wrong.

This adds table-driven unit tests for:

  • uint32ToIPStr: zero, loopback, private, and broadcast addresses.
  • printDualEngineTable: workloads/services/policies render correctly, an
    empty dump prints nothing, and malformed JSON falls back to echoing the
    raw body instead of silently dropping the operator's data.
  • printKernelNativeTable: cluster/route config renders correctly, and
    malformed JSON falls back to the raw body.

No production code changes.

Which issue(s) this PR fixes:
N/A — related to the test gap noted in #1819, but scoped to unit tests for
the existing table-rendering helpers rather than e2e coverage.

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Covers uint32ToIPStr, printDualEngineTable, and printKernelNativeTable,
including empty and malformed-JSON inputs that fall back to raw output.

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
Copilot AI lite review requested due to automatic review settings August 17, 2026 14:37

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kmesh-bot

Copy link
Copy Markdown
Collaborator

Welcome @magic-peach! It looks like this is your first PR to kmesh-net/kmesh 🎉

@kmesh-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bitcoffeeiux for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

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