Skip to content

test: add unit test coverage for the trim_space JMESPath function - #2767

Open
magic-peach wants to merge 1 commit into
kyverno:mainfrom
magic-peach:test/jp-trim-space-coverage
Open

magic-peach wants to merge 1 commit into
kyverno:mainfrom
magic-peach:test/jp-trim-space-coverage

Conversation

@magic-peach

Copy link
Copy Markdown

Explanation

The trim_space JMESPath function had no test file at all, unlike sibling functions such as jpEnv which already have table driven tests. This PR adds one, following the existing pattern. This is a test only addition with no behavior change.

Related issue

No existing issue tracks this specifically, it was found while reviewing test coverage across the JMESPath function package. Happy to open one first if a maintainer would prefer that before review.

Proposed Changes

Added Test_jpTrimSpace in pkg/engine/functions/strings_test.go, covering the missing argument, wrong argument count, and wrong argument type error cases, plus the normal leading and trailing whitespace trim behavior.

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

Ran go test on the package locally, all 5 subtests pass.

jpTrimSpace (the trim_space JMESPath function) had no test file at
all, unlike its sibling functions such as jpEnv which are covered by
a table driven test. Added one following the same pattern, covering
the missing argument, wrong argument count and wrong argument type
error cases plus the normal trim behavior.

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach requested a review from a team as a code owner September 13, 2026 11:07

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.

1 participant