Strengthen test assertions in llm_gateway_test.go using jsonPointerGet#5187
Merged
Strengthen test assertions in llm_gateway_test.go using jsonPointerGet#5187
Conversation
Tests in `pkg/client/llm_gateway_test.go` were using `assert.Contains` on raw file bytes, which passes even when a value lands at the wrong JSON pointer or appears only as a key name. This extends the jsonPointerGet-based assertion pattern (introduced in #5142) to all remaining tests in the file. - Replace raw-string `assert.Contains` with `jsonPointerGet` exact-path assertions in `TestConfigureLLMGateway_CreatesFile`, `_DeepNestedKey`, `_PreservesExistingKeys`, `_ProxyMode`, and the three TLS skip-verify tests - Replace `assert.NotContains` with `_, ok := jsonPointerGet(...); assert.False(t, ok)` in `TestRevertLLMGateway_RemovesKey` and the TLS / Gemini TLS tests - `assert.Contains` is kept where `jsonPointerGet` cannot help: JSONC comment preservation checks and non-string JSON values (e.g. the `permissions` object) Closes #5179
JAORMX
approved these changes
May 5, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5187 +/- ##
==========================================
+ Coverage 67.53% 67.57% +0.03%
==========================================
Files 602 602
Lines 61167 61167
==========================================
+ Hits 41310 41334 +24
+ Misses 16729 16704 -25
- Partials 3128 3129 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens the correctness of pkg/client/llm_gateway_test.go by replacing brittle raw-substring assertions against the serialized settings file with exact JSON-pointer lookups via jsonPointerGet, ensuring tests fail when values land at the wrong path (or only appear as key names).
Changes:
- Replaced multiple
assert.Contains(string(data), ...)checks withjsonPointerGet(data, "/path")+assert.Equal(...)for exact JSON-pointer assertions. - Replaced several
assert.NotContains(...)checks withjsonPointerGet(...); assert.False(t, ok)in revert and TLS-related tests. - Kept raw-substring assertions where the asserted value is non-string JSON (e.g.,
permissions) or where JSONC comment preservation is being tested.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests in
pkg/client/llm_gateway_test.gowere usingassert.Containson raw file bytes, which passes even when a value lands at the wrong JSON pointer or appears only as a key name. This extends the jsonPointerGet-based assertion pattern (introduced in #5142) to all remaining tests in the file.assert.ContainswithjsonPointerGetexact-path assertions inTestConfigureLLMGateway_CreatesFile,_DeepNestedKey,_PreservesExistingKeys,_ProxyMode, and the three TLS skip-verify testsassert.NotContainswith_, ok := jsonPointerGet(...); assert.False(t, ok)inTestRevertLLMGateway_RemovesKeyand the TLS / Gemini TLS testsassert.Containsis kept wherejsonPointerGetcannot help: JSONC comment preservation checks and non-string JSON values (e.g. thepermissionsobject)Fixes #5179
Type of change
Test plan
task test)task test-e2e)task lint-fix)API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Changes
Does this introduce a user-facing change?
Implementation plan
Approved implementation plan
Special notes for reviewers