git: teach *PktlineWriter.Flush() to respond to nil receiver
This commit is contained in:
parent
330e899466
commit
a303cb7e27
@ -87,6 +87,10 @@ func (w *PktlineWriter) Write(p []byte) (int, error) {
|
||||
// writes the pkt-line's FLUSH packet, to signal that it is done writing this
|
||||
// chunk of data.
|
||||
func (w *PktlineWriter) Flush() error {
|
||||
if w == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := w.flush(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -81,6 +81,10 @@ func TestPktlineWriterWritesMultiplePacketsGreaterThanMaxPacketLength(t *testing
|
||||
assertPacketRead(t, pl, nil)
|
||||
}
|
||||
|
||||
func TestPktlineWriterAllowsFlushesOnNil(t *testing.T) {
|
||||
assert.NoError(t, (*PktlineWriter)(nil).Flush())
|
||||
}
|
||||
|
||||
func TestPktlineWriterDoesntWrapItself(t *testing.T) {
|
||||
itself := &PktlineWriter{}
|
||||
nw := NewPktlineWriter(itself, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user