test: assert hpa resource-configured error after the results loop (#1685)

TestHPAAnalyzerWithExistingScaleTargetRefWithoutSpecifyingResources placed
its "if !errorFound { t.Error(...) }" assertion inside the outer
"for _, analysis := range analysisResults" loop. When the analyzer emits
zero results (exactly the regression this test guards against, the
"does not have resource configured." detection breaking), the outer loop
body never runs, the assertion is skipped, and the test passes green.

Move the assertion after the outer loop and break out of it once the error
is found, matching the sibling HPA tests (TestHPAAnalyzerWithUnsuportedScaleTargetRef,
TestHPAAnalyzerWithNonExistentScaleTargetRef). Also drop the dead break that
sat inside the inner loop after its own break. Test-only change.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>
This commit is contained in:
Anas Khan
2026-07-14 13:42:02 +05:30
committed by GitHub
parent f247b3ffb7
commit 1b7c117e8a

View File

@@ -491,14 +491,14 @@ func TestHPAAnalyzerWithExistingScaleTargetRefWithoutSpecifyingResources(t *test
errorFound = true
break
}
if errorFound {
break
}
}
if !errorFound {
t.Error("expected error 'does not have resource configured.' not found in analysis results")
if errorFound {
break
}
}
if !errorFound {
t.Error("expected error 'does not have resource configured.' not found in analysis results")
}
}
func TestHPAAnalyzerNamespaceFiltering(t *testing.T) {