diff options
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") +} |