From ed74c6a615ece8904080e577e90012d9710a354e Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Tue, 22 Sep 2026 19:44:20 -0400 Subject: [PATCH 1/2] feat(helpers): add ScenarioValidationMessage Return the message of a scenario's IntegrationTestScenarioValid condition, so callers can surface why a scenario was marked invalid. Assisted-by: Claude Signed-off-by: Wayne Sun --- helpers/scenario.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helpers/scenario.go b/helpers/scenario.go index 802f8e383..82746a4ec 100644 --- a/helpers/scenario.go +++ b/helpers/scenario.go @@ -59,3 +59,11 @@ func SetScenarioIntegrationStatusAsValid(scenario *v1beta2.IntegrationTestScenar func IsIntegrationTestScenarioOptional(scenario *v1beta2.IntegrationTestScenario) bool { return metadata.HasLabelWithValue(scenario, "test.appstudio.openshift.io/optional", "true") } + +// ScenarioValidationMessage returns the message of the scenario's +// IntegrationTestScenarioValid condition, or "" when the condition has not +// been set yet. +func ScenarioValidationMessage(scenario *v1beta2.IntegrationTestScenario) string { + cond := meta.FindStatusCondition(scenario.Status.Conditions, IntegrationTestScenarioValid) + return cond.Message +} From eb6f60d96db89aa54bd401990aac7245aee52608 Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Tue, 22 Sep 2026 19:44:45 -0400 Subject: [PATCH 2/2] fix(helpers): return empty message when the condition is unset FindStatusCondition returns nil for a scenario that has not been validated yet, so ScenarioValidationMessage dereferenced nil instead of returning the empty string its doc comment promises. Guard it and cover both cases. Assisted-by: Claude Signed-off-by: Wayne Sun --- helpers/scenario.go | 3 +++ helpers/scenario_test.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/helpers/scenario.go b/helpers/scenario.go index 82746a4ec..05b4d10a7 100644 --- a/helpers/scenario.go +++ b/helpers/scenario.go @@ -65,5 +65,8 @@ func IsIntegrationTestScenarioOptional(scenario *v1beta2.IntegrationTestScenario // been set yet. func ScenarioValidationMessage(scenario *v1beta2.IntegrationTestScenario) string { cond := meta.FindStatusCondition(scenario.Status.Conditions, IntegrationTestScenarioValid) + if cond == nil { + return "" + } return cond.Message } diff --git a/helpers/scenario_test.go b/helpers/scenario_test.go index 31c678c07..197ca78d4 100644 --- a/helpers/scenario_test.go +++ b/helpers/scenario_test.go @@ -23,6 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/konflux-ci/integration-service/api/v1beta2" + "github.com/konflux-ci/integration-service/helpers" ) var _ = Describe("Gitops functions for managing Snapshots", Ordered, func() { @@ -70,3 +71,16 @@ var _ = Describe("Gitops functions for managing Snapshots", Ordered, func() { Expect(err == nil || errors.IsNotFound(err)).To(BeTrue()) }) }) + +var _ = Describe("ScenarioValidationMessage", func() { + It("returns an empty message when the condition has not been set", func() { + scenario := &v1beta2.IntegrationTestScenario{} + Expect(helpers.ScenarioValidationMessage(scenario)).To(BeEmpty()) + }) + + It("returns the message of the IntegrationTestScenarioValid condition", func() { + scenario := &v1beta2.IntegrationTestScenario{} + helpers.SetScenarioIntegrationStatusAsInvalid(scenario, "pipeline not found") + Expect(helpers.ScenarioValidationMessage(scenario)).To(Equal("pipeline not found")) + }) +})