diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-11-30 17:24:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 17:24:11 +0100 |
commit | bd3dd4d421299699854bfe0353aae312bcf8c97c (patch) | |
tree | 60f22b556b929143955bd54e6ac7ae69563308ed /plumbing/protocol/packp/sideband/muxer_test.go | |
parent | b0d756c93d8deb5d4c6a129c5bd3163dddd10132 (diff) | |
download | go-git-bd3dd4d421299699854bfe0353aae312bcf8c97c.tar.gz |
protocol/packp: sideband muxer and demuxer (#143)
* format/pakp: sideband demuxer
* format/pakp: sideband muxer
* format/pakp: sideband demuxer and muxer
* protocol/pakp: sideband demuxer and muxer
* documentation and improvements
* improvements
* handle scan errors properly
Diffstat (limited to 'plumbing/protocol/packp/sideband/muxer_test.go')
-rw-r--r-- | plumbing/protocol/packp/sideband/muxer_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/sideband/muxer_test.go b/plumbing/protocol/packp/sideband/muxer_test.go new file mode 100644 index 0000000..38fc4bd --- /dev/null +++ b/plumbing/protocol/packp/sideband/muxer_test.go @@ -0,0 +1,39 @@ +package sideband + +import ( + "bytes" + + . "gopkg.in/check.v1" +) + +func (s *SidebandSuite) TestMuxerWrite(c *C) { + buf := bytes.NewBuffer(nil) + + m := NewMuxer(Sideband, buf) + + n, err := m.Write(bytes.Repeat([]byte{'F'}, (MaxPackedSize-1)*2)) + c.Assert(err, IsNil) + c.Assert(n, Equals, 1998) + c.Assert(buf.Len(), Equals, 2008) +} + +func (s *SidebandSuite) TestMuxerWriteChannelMultipleChannels(c *C) { + buf := bytes.NewBuffer(nil) + + m := NewMuxer(Sideband, buf) + + n, err := m.WriteChannel(PackData, bytes.Repeat([]byte{'D'}, 4)) + c.Assert(err, IsNil) + c.Assert(n, Equals, 4) + + n, err = m.WriteChannel(ProgressMessage, bytes.Repeat([]byte{'P'}, 4)) + c.Assert(err, IsNil) + c.Assert(n, Equals, 4) + + n, err = m.WriteChannel(PackData, bytes.Repeat([]byte{'D'}, 4)) + c.Assert(err, IsNil) + c.Assert(n, Equals, 4) + + c.Assert(buf.Len(), Equals, 27) + c.Assert(buf.String(), Equals, "0009\x01DDDD0009\x02PPPP0009\x01DDDD") +} |