Reconcile reporting tests and boundaries
This commit is contained in:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user