Skip to content

Commit

Permalink
fix(STONTEINTG-573): fix confusing message about failed test
Browse files Browse the repository at this point in the history
Signed-off-by: Jing Qi <[email protected]>

Update the log message when there are no integration tests
  • Loading branch information
jinqi7 committed Sep 7, 2023
1 parent 1241de1 commit 3f078c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
25 changes: 15 additions & 10 deletions gitops/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,22 @@ func HaveAppStudioTestsSucceeded(snapshot *applicationapiv1alpha1.Snapshot) bool
func CanSnapshotBePromoted(snapshot *applicationapiv1alpha1.Snapshot) (bool, []string) {
canBePromoted := true
reasons := make([]string, 0)
if !HaveAppStudioTestsSucceeded(snapshot) {
if !HaveAppStudioTestsFinished(snapshot) {
canBePromoted = false
reasons = append(reasons, "the Snapshot hasn't passed all required integration tests")
}
if !IsSnapshotValid(snapshot) {
canBePromoted = false
reasons = append(reasons, "the Snapshot is invalid")
}
if IsSnapshotCreatedByPACPullRequestEvent(snapshot) {
canBePromoted = false
reasons = append(reasons, "the Snapshot was created for a PaC pull request event")
reasons = append(reasons, "the Snapshot has not yet finished testing")
} else {
if !HaveAppStudioTestsSucceeded(snapshot) {
canBePromoted = false
reasons = append(reasons, "the Snapshot hasn't passed all required integration tests")
}
if !IsSnapshotValid(snapshot) {
canBePromoted = false
reasons = append(reasons, "the Snapshot is invalid")
}
if IsSnapshotCreatedByPACPullRequestEvent(snapshot) {
canBePromoted = false
reasons = append(reasons, "the Snapshot was created for a PaC pull request event")
}
}
return canBePromoted, reasons
}
Expand Down
7 changes: 7 additions & 0 deletions gitops/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ var _ = Describe("Gitops functions for managing Snapshots", Ordered, func() {
Expect(err == nil || errors.IsNotFound(err)).To(BeTrue())
})

It("ensures the a decision can be made to NOT promote when the snaphot has not been marked as passed/failed", func() {
canBePromoted, reasons := gitops.CanSnapshotBePromoted(hasSnapshot)
Expect(canBePromoted).To(BeFalse())
Expect(reasons).To(HaveLen(1))
Expect(reasons[0]).To(Equal("the Snapshot has not yet finished testing"))
})

It("ensures the Snapshots status can be marked as passed", func() {
updatedSnapshot, err := gitops.MarkSnapshotAsPassed(k8sClient, ctx, hasSnapshot, "Test message")
Expect(err).To(BeNil())
Expand Down

0 comments on commit 3f078c2

Please sign in to comment.