Stop persisting notification receipts
This commit is contained in:
@@ -197,12 +197,12 @@ func TestGenerateDetailedCompletesRetainedReportWorkflows(t *testing.T) {
|
||||
if !bytes.Equal(executor.request.DataPackage, persisted) {
|
||||
t.Fatal("executor data package differs from exact persisted YAML bytes")
|
||||
}
|
||||
managed, readErr := os.ReadFile(result.ReportPath)
|
||||
if readErr != nil || !strings.Contains(string(managed), test.wantOutput) {
|
||||
t.Fatalf("managed report = %q, error %v, want generated template output %q", managed, readErr, test.wantOutput)
|
||||
renderedReport, readErr := os.ReadFile(result.ReportPath)
|
||||
if readErr != nil || !strings.Contains(string(renderedReport), test.wantOutput) {
|
||||
t.Fatalf("rendered report = %q, error %v, want generated template output %q", renderedReport, readErr, test.wantOutput)
|
||||
}
|
||||
copied, readErr := os.ReadFile(outputPath)
|
||||
if readErr != nil || !bytes.Equal(copied, managed) || result.OutputPath != outputPath {
|
||||
if readErr != nil || !bytes.Equal(copied, renderedReport) || result.OutputPath != outputPath {
|
||||
t.Fatalf("output mismatch/error/path = %v/%q", readErr, result.OutputPath)
|
||||
}
|
||||
if len(notifier.requests) != 1 || notifier.requests[0].ReportPath != outputPath {
|
||||
@@ -217,9 +217,9 @@ func TestGenerateDetailedCompletesRetainedReportWorkflows(t *testing.T) {
|
||||
if strings.Join(notifier.requests[0].BundlePaths, "\n") != strings.Join(wantBundlePaths, "\n") {
|
||||
t.Fatalf("bundle paths = %#v, want %#v", notifier.requests[0].BundlePaths, wantBundlePaths)
|
||||
}
|
||||
managedName := filepath.Base(result.ReportPath)
|
||||
if !strings.HasPrefix(managedName, "report.") || !strings.Contains(managedName, "_"+test.name) || !strings.HasSuffix(managedName, ".md") || filepath.Base(result.OutputPath) != test.name+".md" {
|
||||
t.Fatalf("output names = managed %q copy %q", result.ReportPath, result.OutputPath)
|
||||
renderedName := filepath.Base(result.ReportPath)
|
||||
if !strings.HasPrefix(renderedName, "report.") || !strings.Contains(renderedName, "_"+test.name) || !strings.HasSuffix(renderedName, ".md") || filepath.Base(result.OutputPath) != test.name+".md" {
|
||||
t.Fatalf("output names = rendered %q copy %q", result.ReportPath, result.OutputPath)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -465,7 +465,6 @@ func TestGenerateDetailedRetainsInspectableArtifactsAfterApplicationFailures(t *
|
||||
wantContext bool
|
||||
wantReport bool
|
||||
wantOutput bool
|
||||
wantNotify bool
|
||||
}{
|
||||
{name: "generated text decode", raw: `{`, wantRaw: true},
|
||||
{name: "generated text domain", raw: `{}`, wantRaw: true},
|
||||
@@ -484,7 +483,7 @@ func TestGenerateDetailedRetainsInspectableArtifactsAfterApplicationFailures(t *
|
||||
}, wantRaw: true, wantNormalized: true, wantContext: true},
|
||||
{name: "notification", raw: validDailyWorkflowJSON(), configure: func(_ *GenerateRequest, notifier *workflowNotifier) {
|
||||
notifier.err = errors.New("notification rejected")
|
||||
}, wantRaw: true, wantNormalized: true, wantContext: true, wantReport: true, wantOutput: true, wantNotify: true},
|
||||
}, wantRaw: true, wantNormalized: true, wantContext: true, wantReport: true, wantOutput: true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -512,8 +511,8 @@ func TestGenerateDetailedRetainsInspectableArtifactsAfterApplicationFailures(t *
|
||||
}
|
||||
if (result.GeneratedTextRawPath != "") != test.wantRaw || (result.GeneratedTextPath != "") != test.wantNormalized ||
|
||||
(result.RenderContextPath != "") != test.wantContext || (result.ReportPath != "") != test.wantReport ||
|
||||
(result.OutputPath != "") != test.wantOutput || (result.NotificationPath != "") != test.wantNotify {
|
||||
t.Fatalf("reached paths = raw %q normalized %q context %q report %q output %q notification %q", result.GeneratedTextRawPath, result.GeneratedTextPath, result.RenderContextPath, result.ReportPath, result.OutputPath, result.NotificationPath)
|
||||
(result.OutputPath != "") != test.wantOutput {
|
||||
t.Fatalf("reached paths = raw %q normalized %q context %q report %q output %q", result.GeneratedTextRawPath, result.GeneratedTextPath, result.RenderContextPath, result.ReportPath, result.OutputPath)
|
||||
}
|
||||
if test.wantRaw {
|
||||
persisted, readErr := os.ReadFile(result.GeneratedTextRawPath)
|
||||
@@ -524,6 +523,9 @@ func TestGenerateDetailedRetainsInspectableArtifactsAfterApplicationFailures(t *
|
||||
if test.name == "notification" && (len(notifier.requests) != 1 || notifier.requests[0].ReportPath != result.OutputPath) {
|
||||
t.Fatalf("notification requests = %#v", notifier.requests)
|
||||
}
|
||||
if test.name == "notification" && result.Metadata.NotificationPath != "" {
|
||||
t.Fatalf("notification metadata retains a receipt path: %#v", result.Metadata)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user