diff --git a/status/status.go b/status/status.go index 0ef9b5811..7112c7e51 100644 --- a/status/status.go +++ b/status/status.go @@ -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.)", + integrationTestStatusDetail.Details, pipelineRunName, pipelineRunURL) return text, nil } - return "", fmt.Errorf("error while getting the pipelineRun %s: %w", pipelineRunName, err) } diff --git a/status/status_test.go b/status/status_test.go index 5b5916fd5..40d00787e 100644 --- a/status/status_test.go +++ b/status/status_test.go @@ -885,6 +885,28 @@ var _ = Describe("Status Adapter", func() { }) + // 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"