diff options
author | Paulo Gomes <pjbgf@linux.com> | 2024-04-27 07:06:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-27 07:06:13 +0100 |
commit | d6bb286bdb909df15d4584df11251a8315f35b1a (patch) | |
tree | 9f64982e8e218f7a29512224d183e9d96eb731fb /plumbing/protocol/packp/sideband/demux_test.go | |
parent | 1ddd78a55f803c9ed0fac6a56d201271fef21eeb (diff) | |
parent | 59b792bf8a814ad5d7810c51a18e9f618153ace8 (diff) | |
download | go-git-d6bb286bdb909df15d4584df11251a8315f35b1a.tar.gz |
Merge pull request #1084 from aymanbagabas/sideband-flush
plumbing: fix sideband demux on flush
Diffstat (limited to 'plumbing/protocol/packp/sideband/demux_test.go')
-rw-r--r-- | plumbing/protocol/packp/sideband/demux_test.go | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/plumbing/protocol/packp/sideband/demux_test.go b/plumbing/protocol/packp/sideband/demux_test.go index 8f23353..1ba3ad9 100644 --- a/plumbing/protocol/packp/sideband/demux_test.go +++ b/plumbing/protocol/packp/sideband/demux_test.go @@ -105,8 +105,34 @@ func (s *SidebandSuite) TestDecodeWithProgress(c *C) { c.Assert(progress, DeepEquals, []byte{'F', 'O', 'O', '\n'}) } -func (s *SidebandSuite) TestDecodeWithUnknownChannel(c *C) { +func (s *SidebandSuite) TestDecodeFlushEOF(c *C) { + expected := []byte("abcdefghijklmnopqrstuvwxyz") + + input := bytes.NewBuffer(nil) + e := pktline.NewEncoder(input) + e.Encode(PackData.WithPayload(expected[0:8])) + e.Encode(ProgressMessage.WithPayload([]byte{'F', 'O', 'O', '\n'})) + e.Encode(PackData.WithPayload(expected[8:16])) + e.Encode(PackData.WithPayload(expected[16:26])) + e.Flush() + e.Encode(PackData.WithPayload([]byte("bar\n"))) + + output := bytes.NewBuffer(nil) + content := bytes.NewBuffer(nil) + d := NewDemuxer(Sideband64k, input) + d.Progress = output + + n, err := content.ReadFrom(d) + c.Assert(err, IsNil) + c.Assert(n, Equals, int64(26)) + c.Assert(content.Bytes(), DeepEquals, expected) + progress, err := io.ReadAll(output) + c.Assert(err, IsNil) + c.Assert(progress, DeepEquals, []byte{'F', 'O', 'O', '\n'}) +} + +func (s *SidebandSuite) TestDecodeWithUnknownChannel(c *C) { buf := bytes.NewBuffer(nil) e := pktline.NewEncoder(buf) e.Encode([]byte{'4', 'F', 'O', 'O', '\n'}) @@ -150,5 +176,4 @@ func (s *SidebandSuite) TestDecodeErrMaxPacked(c *C) { n, err := io.ReadFull(d, content) c.Assert(err, Equals, ErrMaxPackedExceeded) c.Assert(n, Equals, 0) - } |