Reconcile reporting tests and boundaries

This commit is contained in:
2026-10-26 03:51:14 +00:00
parent 6264a87183
commit a6c0fb5b0d
7 changed files with 124 additions and 106 deletions

View File

@@ -49,6 +49,31 @@ func TestReporterOutputSubmitsOnWrite(t *testing.T) {
}
}
type callerOwnedWriter struct {
bytes.Buffer
closeCalls int
}
func (w *callerOwnedWriter) Close() error {
w.closeCalls++
return nil
}
func TestReporterLeavesCallerWriterOpen(t *testing.T) {
destination := &callerOwnedWriter{}
reporter := newReporter(Streams{Out: destination})
_, _ = reporter.Output().Write([]byte("report"))
_ = reporter.RenderOutput(func(writer io.Writer) error {
_, err := io.WriteString(writer, " rendered")
return err
})
_ = reporter.finalize(Success(), nil)
if destination.String() != "report rendered" || destination.closeCalls != 0 {
t.Fatalf("destination = %q, Close calls = %d", destination.String(), destination.closeCalls)
}
}
func TestReporterQuietOutputDiscardsSuccessfully(t *testing.T) {
var destination bytes.Buffer
reporter := newReporter(Streams{Out: &destination})