Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions helpers/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,14 @@ 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] scope-intent-mismatch

The PR title and body declare this change as temporary ('do not merge', 'will be closed without merging'), yet it adds a new exported function ScenarioValidationMessage to the production helpers package. An exported symbol is a permanent API surface addition. No linked issue authorizes this addition. The function is a trivial read-only accessor following existing patterns in the file.

Suggested fix: If the function is genuinely needed only for steering validation, scope it to test files or an unexported symbol. If intended to remain, open a proper feature issue.

cond := meta.FindStatusCondition(scenario.Status.Conditions, IntegrationTestScenarioValid)
if cond == nil {
return ""
}
return cond.Message
}
14 changes: 14 additions & 0 deletions helpers/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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"))
})
})
Loading