Skip to content

test: add unit tests for pkg/constants#1762

Open
Shruti2110-coder wants to merge 1 commit into
kmesh-net:mainfrom
Shruti2110-coder:test/constants-package
Open

test: add unit tests for pkg/constants#1762
Shruti2110-coder wants to merge 1 commit into
kmesh-net:mainfrom
Shruti2110-coder:test/constants-package

Conversation

@Shruti2110-coder

Copy link
Copy Markdown

What this PR does

Adds unit tests for pkg/constants package.

Tests added

  • TestDataPlaneModeValues
  • TestDataPlaneLabels
  • TestControlCommandIPs
  • TestOperCodes
  • TestBPFLogLevels
  • TestIPFamilyConstants
  • TestTailCallIndices
  • TestEnabledDisabled
  • TestTrafficDirection

How to verify

go test ./pkg/constants/... -v

All 9 tests pass locally on macOS (arm64) without requiring Linux/eBPF build prerequisites.

Signed-off-by: Shruti2110-coder <your-github-email@example.com>
Copilot AI review requested due to automatic review settings June 16, 2026 18:51
@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 lizhencheng9527 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

@kmesh-bot

Copy link
Copy Markdown
Collaborator

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

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Go test file to validate that exported constants in pkg/constants retain their expected values, helping prevent accidental breaking changes.

Changes:

  • Introduces unit tests for dataplane mode strings/labels/annotations.
  • Adds assertions for control command IPs, operation codes, log levels, and various numeric constants.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces unit testing for the pkg/constants package to validate the values of various configuration and operational constants used throughout the project. By implementing these tests, the codebase gains better stability and ensures that critical constants remain consistent across builds.

Highlights

  • Test Coverage: Added a comprehensive suite of unit tests for the pkg/constants package to ensure the integrity of defined constants.
  • Verification: The new tests cover various areas including data plane modes, BPF log levels, operation codes, and traffic direction, all of which pass without requiring specific build environments.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


Constants set in stone and code, / To keep the data on the road. / With tests now written, clear and bright, / The logic stays within the light.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request adds a new test file, pkg/constants/constants_test.go, which contains unit tests to validate various constants used in the project, such as data plane modes, labels, control command IPs, operation codes, BPF log levels, IP family constants, tail call indices, enabled/disabled states, and traffic directions. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants