Attribute reader shutdown failures to checks that read content

This commit is contained in:
2026-10-09 03:07:13 +00:00
parent 6eec022bb0
commit 7d92c477c2
4 changed files with 44 additions and 15 deletions

View File

@@ -28,17 +28,29 @@ done
printf 'batch process failed during cleanup\n' >&2
exit 23`)
err := Run(context.Background(), lifecycleRequest(repository, commit))
var failure *Failure
if !errors.As(err, &failure) || failure.Check != GoFormat {
t.Fatalf("Run() error = %v, want cleanup failure attributed to GoFormat", err)
}
var exitErr *exec.ExitError
if !errors.As(failure.Cause, &exitErr) || exitErr.ExitCode() != 23 {
t.Fatalf("cleanup cause = %v, want Git child exit code 23", failure.Cause)
}
if !strings.Contains(failure.Cause.Error(), "batch process failed during cleanup") {
t.Fatalf("cleanup cause = %v, want captured Git stderr", failure.Cause)
for _, testCase := range []struct {
name string
markdown *MarkdownSettings
}{
{name: "formatting only"},
{name: "later Markdown check without files", markdown: &MarkdownSettings{}},
} {
t.Run(testCase.name, func(t *testing.T) {
request := lifecycleRequest(repository, commit)
request.Settings.Markdown = testCase.markdown
err := Run(context.Background(), request)
var failure *Failure
if !errors.As(err, &failure) || failure.Check != GoFormat {
t.Fatalf("Run() error = %v, want cleanup failure attributed to GoFormat", err)
}
var exitErr *exec.ExitError
if !errors.As(failure.Cause, &exitErr) || exitErr.ExitCode() != 23 {
t.Fatalf("cleanup cause = %v, want Git child exit code 23", failure.Cause)
}
if !strings.Contains(failure.Cause.Error(), "batch process failed during cleanup") {
t.Fatalf("cleanup cause = %v, want captured Git stderr", failure.Cause)
}
})
}
}