Skip to content

Commit 82e4670

Browse files
authored
fix: unnecessary %% escapes in test messages and invalid jq parent filter (#314)
- Remove unnecessary %% escapes in testify assert messages that have no format args (testify only applies fmt.Sprintf when len(msgAndArgs) > 1; single-string messages are used as-is, so %% prints literally as %%) - Replace invalid jq "parent" filter in verify-helm-schema-fields.sh with bash parameter expansion to strip trailing .properties suffix, which gives the correct parent path for additionalProperties check Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 1c32554 commit 82e4670

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

hack/verify-helm-schema-fields.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ for k in sorted(props.keys()):
6868
if ! echo "$schema_fields" | grep -qx "$field"; then
6969
# Only warn if the section uses additionalProperties: false
7070
local strict
71-
strict=$(jq -r "${jq_path} | parent | .additionalProperties // true" "$SCHEMA" 2>/dev/null)
71+
local section_path="${jq_path%.properties}"
72+
strict=$(jq -r "${section_path} | .additionalProperties // true" "$SCHEMA" 2>/dev/null)
7273
if [ "$strict" = "false" ]; then
7374
echo "WARNING: defaults.${section} CRD has '${field}' but schema omits it (users cannot set this via Helm)"
7475
fi

internal/recommendation/chain_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestRecommendationEngine_RealisticCPU(t *testing.T) {
6767
// → bounds OK → change filter: 241m vs 500m = 52% decrease > 50%
6868
// → capped at 500m - 250m = 250m.
6969
assert.Equal(t, int64(250), recommended.MilliValue(),
70-
"50%% max decrease from 500m should cap at 250m")
70+
"50% max decrease from 500m should cap at 250m")
7171
}
7272

7373
func TestRecommendationEngine_RealisticMemory(t *testing.T) {
@@ -111,7 +111,7 @@ func TestRecommendationEngine_RealisticMemory(t *testing.T) {
111111
assert.Less(t, recommended.Value(), int64(350*1024*1024),
112112
"recommendation should be below ~350Mi (overhead + confidence, not capped)")
113113
assert.Empty(t, explanation.ChangeFilterApplied,
114-
"~39.8%% decrease should not trigger the 50%% max change cap")
114+
"~39.8% decrease should not trigger the 50% max change cap")
115115
assert.True(t, recommended.Cmp(current) < 0,
116116
"recommendation %s should be less than current %s", recommended.String(), current.String())
117117
}
@@ -151,7 +151,7 @@ func TestRecommendationEngine_SmallChangeFiltered(t *testing.T) {
151151
current := resource.MustParse("500m")
152152
recommended, changed := engine.Recommend(profile, current)
153153

154-
assert.False(t, changed, "change <10%% should be filtered out")
154+
assert.False(t, changed, "change <10% should be filtered out")
155155
assert.Equal(t, current.MilliValue(), recommended.MilliValue(),
156156
"filtered recommendation should equal current")
157157
}
@@ -176,7 +176,7 @@ func TestRecommendationEngine_LargeChangeCapped(t *testing.T) {
176176
recommended, changed := engine.Recommend(profile, current)
177177
assert.True(t, changed)
178178
assert.Equal(t, int64(300), recommended.MilliValue(),
179-
"50%% max increase from 200m should cap at 300m")
179+
"50% max increase from 200m should cap at 300m")
180180
}
181181

182182
func TestRecommendationEngine_HighVsLowConfidence(t *testing.T) {

internal/recommendation/change_filter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestChangeFilter_BinarySIMemoryCapping(t *testing.T) {
117117
// The code computes in millis: current=536870912000, delta=268435456000,
118118
// capped=805306368000, then divides by 1000 and ceils: 805306368.
119119
assert.Equal(t, int64(805306368), result.Value(),
120-
"50%% increase from 512Mi should produce 768Mi")
120+
"50% increase from 512Mi should produce 768Mi")
121121
}
122122

123123
func TestChangeFilter_BinarySIMemoryDecreaseCapping(t *testing.T) {
@@ -135,7 +135,7 @@ func TestChangeFilter_BinarySIMemoryDecreaseCapping(t *testing.T) {
135135
assert.Equal(t, resource.BinarySI, result.Format)
136136
// 1Gi = 1073741824 bytes. 50% decrease = 536870912.
137137
assert.Equal(t, int64(536870912), result.Value(),
138-
"50%% decrease from 1Gi should produce 512Mi")
138+
"50% decrease from 1Gi should produce 512Mi")
139139
}
140140

141141
func TestChangeFilter_ZeroCurrent(t *testing.T) {

0 commit comments

Comments
 (0)