Skip to content
Open
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
5 changes: 3 additions & 2 deletions status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ func generateText(ctx context.Context, client client.Client, integrationTestStat
if err != nil {
if apierrors.IsNotFound(err) {
log.Error(err, "Failed to fetch pipelineRun", "pipelineRun.Name", pipelineRunName)
text := fmt.Sprintf("%s\n\n\n(Failed to fetch test result details because pipelineRun %s/%s can not be found.)", integrationTestStatusDetail.Details, snapshot.Namespace, pipelineRunName)
pipelineRunURL := FormatPipelineURL(pipelineRunName, snapshot.Namespace, log)
text := fmt.Sprintf("%s\n\n\n(Failed to fetch test result details because pipelineRun [%s](%s) can not be found.)",
Comment thread
ainephelan365 marked this conversation as resolved.
Comment thread
ainephelan365 marked this conversation as resolved.
Comment thread
ainephelan365 marked this conversation as resolved.
integrationTestStatusDetail.Details, pipelineRunName, pipelineRunURL)
return text, nil
Comment thread
ainephelan365 marked this conversation as resolved.
}

return "", fmt.Errorf("error while getting the pipelineRun %s: %w", pipelineRunName, err)
}

Expand Down
22 changes: 22 additions & 0 deletions status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,28 @@ var _ = Describe("Status Adapter", func() {

})

Comment thread
ainephelan365 marked this conversation as resolved.
// Verifying that pruned PipelineRun produces a fallback message rather than an error
It("check that pruned PipelineRun produces a fallback message rather than an error", func() {
detail := newIntegrationTestStatusDetail(integrationteststatus.IntegrationTestStatusTestPassed, false)
detail.TestPipelineRunName = "pruned-pipelinerun"

notFoundClient := &MockK8sClient{
err: &errors.StatusError{ErrStatus: metav1.Status{Reason: metav1.StatusReasonNotFound}},
}

testReport, err := status.GenerateTestReport(context.Background(), notFoundClient, detail, hasSnapshot, "component-sample")
Expect(err).NotTo(HaveOccurred())
Expect(testReport.Text).To(ContainSubstring("(Failed to fetch test result details because pipelineRun [pruned-pipelinerun](https://definetly.not.prod/preview/application-pipeline/ns/default/pipelinerun/pruned-pipelinerun) can not be found.)"))

genericErrorClient := &MockK8sClient{
err: fmt.Errorf("unexpected client error"),
}

testReport, err = status.GenerateTestReport(context.Background(), genericErrorClient, detail, hasSnapshot, "component-sample")
Expect(err).To(HaveOccurred())
Expect(testReport).To(BeNil())
})

Describe("SnapshotReportStatus (SRS)", func() {
const (
scenarioName = "test-scenario"
Expand Down
Loading