Skip to content

Commit a8c2ee4

Browse files
committed
feat(STONEINTG-1546): add plr link to git report
Provide a linkable pipelinerun name when reporting integration test with pruned pipelinerun. Signed-off-by: aphelan <aphelan@redhat.com>
1 parent 8f9e64f commit a8c2ee4

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

status/status.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,11 @@ func generateText(ctx context.Context, client client.Client, integrationTestStat
302302
if err != nil {
303303
if apierrors.IsNotFound(err) {
304304
log.Error(err, "Failed to fetch pipelineRun", "pipelineRun.Name", pipelineRunName)
305-
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)
305+
pipelineRunURL := FormatPipelineURL(pipelineRunName, snapshot.Namespace, log)
306+
text := fmt.Sprintf("%s\n\n\n(Failed to fetch test result details because pipelineRun [%s](%s) can not be found.)",
307+
integrationTestStatusDetail.Details, pipelineRunName, pipelineRunURL)
306308
return text, nil
307309
}
308-
309310
return "", fmt.Errorf("error while getting the pipelineRun %s: %w", pipelineRunName, err)
310311
}
311312

status/status_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,28 @@ var _ = Describe("Status Adapter", func() {
885885

886886
})
887887

888+
// Verifying that pruned PipelineRun produces a fallback message rather than an error
889+
It("check that pruned PipelineRun produces a fallback message rather than an error", func() {
890+
detail := newIntegrationTestStatusDetail(integrationteststatus.IntegrationTestStatusTestPassed, false)
891+
detail.TestPipelineRunName = "pruned-pipelinerun"
892+
893+
notFoundClient := &MockK8sClient{
894+
err: &errors.StatusError{ErrStatus: metav1.Status{Reason: metav1.StatusReasonNotFound}},
895+
}
896+
897+
testReport, err := status.GenerateTestReport(context.Background(), notFoundClient, detail, hasSnapshot, "component-sample")
898+
Expect(err).NotTo(HaveOccurred())
899+
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.)"))
900+
901+
genericErrorClient := &MockK8sClient{
902+
err: fmt.Errorf("unexpected client error"),
903+
}
904+
905+
testReport, err = status.GenerateTestReport(context.Background(), genericErrorClient, detail, hasSnapshot, "component-sample")
906+
Expect(err).To(HaveOccurred())
907+
Expect(testReport).To(BeNil())
908+
})
909+
888910
Describe("SnapshotReportStatus (SRS)", func() {
889911
const (
890912
scenarioName = "test-scenario"

0 commit comments

Comments
 (0)