Skip to content

[Test] Add unit test coverage for pkg/constants #1644

@shubhtrek

Description

@shubhtrek

The Issue
Currently, pkg/constants/constants.go contains the "source of truth" for Kmesh (eBPF modes, service names, and K8s labels). However, this file has no unit tests.

Since these strings are used as keys in eBPF maps and by the Kmesh controller, any accidental typo during a future refactor could cause the data plane to fail silently.

The Proposal
I want to add constants_test.go to ensure:

Consistency: Modes like MeshModeAds and MeshModeWorkload stay mapped to their correct strings.

Safety: Core labels (e.g., DataPlaneModeLabel) aren't accidentally modified.

Sanity: No critical constant is initialized as an empty string.

Plan
I am a Go developer and have Kmesh running locally. I will:

Create a table-driven test in pkg/constants/constants_test.go.

Verify all existing constants.

Ensure the PR passes all project linting/CI.

Please assign this to me! I'm excited to help make Kmesh more robust.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions