Keep failed processing reports consistent
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/reporting"
|
||||
commandkit "go.maximumdirect.net/commandkit"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestPreparedDeliveryFollowsReportingMode(t *testing.T) {
|
||||
@@ -76,8 +77,9 @@ func TestPreparedDeliveryFollowsReportingMode(t *testing.T) {
|
||||
|
||||
func TestDeliveryFailureSuppressesCompletionSummary(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
t.Chdir(dir)
|
||||
for name, contents := range map[string]string{
|
||||
"config.yml": "version: 3\npipeline:\n stages: []\nreporting:\n enabled: false\n",
|
||||
"config.yml": "version: 3\npipeline:\n stages: []\n",
|
||||
"transcript.json": `[{"speaker":"Alice","start":0,"end":1,"text":"hello"}]`,
|
||||
} {
|
||||
if err := os.WriteFile(filepath.Join(dir, name), []byte(contents), 0644); err != nil {
|
||||
@@ -105,6 +107,24 @@ func TestDeliveryFailureSuppressesCompletionSummary(t *testing.T) {
|
||||
if outcome.Status == 0 || strings.Contains(stderr.String(), "Completed:") {
|
||||
t.Fatalf("status=%d stderr=%q", outcome.Status, stderr.String())
|
||||
}
|
||||
var errs reporting.ErrorsDocument
|
||||
var recoveries reporting.RecoveriesDocument
|
||||
for path, target := range map[string]any{"errors.yml": &errs, "recoveries.yml": &recoveries} {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := yaml.Unmarshal(data, target); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if errs.Status != reporting.StatusFailed || recoveries.Status != reporting.StatusFailed ||
|
||||
errs.Summary.RunErrors == nil || *errs.Summary.RunErrors != 1 ||
|
||||
recoveries.Summary.RunErrors == nil || *recoveries.Summary.RunErrors != 1 ||
|
||||
len(errs.Errors) != 1 || errs.Errors[0].Reason != "output_failure" {
|
||||
t.Fatalf("failed output reports disagree: %+v %+v", errs, recoveries)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type shortProcessWriter struct{}
|
||||
|
||||
Reference in New Issue
Block a user