Debian Codegraph @

plumbing/protocol/packp/sideband/muxer_test.go

raw
1 package sideband
2
3 import (
4 "bytes"
5
6 . "gopkg.in/check.v1"
7 )
8
9 func (s *SidebandSuite) TestMuxerWrite(c *C) {
10 buf := bytes.NewBuffer(nil)
11
12 m := NewMuxer(Sideband, buf)
13
14 n, err := m.Write(bytes.Repeat([]byte{'F'}, (MaxPackedSize-1)*2))
15 c.Assert(err, IsNil)
16 c.Assert(n, Equals, 1998)
17 c.Assert(buf.Len(), Equals, 2008)
18 }
19
20 func (s *SidebandSuite) TestMuxerWriteChannelMultipleChannels(c *C) {
21 buf := bytes.NewBuffer(nil)
22
23 m := NewMuxer(Sideband, buf)
24
25 n, err := m.WriteChannel(PackData, bytes.Repeat([]byte{'D'}, 4))
26 c.Assert(err, IsNil)
27 c.Assert(n, Equals, 4)
28
29 n, err = m.WriteChannel(ProgressMessage, bytes.Repeat([]byte{'P'}, 4))
30 c.Assert(err, IsNil)
31 c.Assert(n, Equals, 4)
32
33 n, err = m.WriteChannel(PackData, bytes.Repeat([]byte{'D'}, 4))
34 c.Assert(err, IsNil)
35 c.Assert(n, Equals, 4)
36
37 c.Assert(buf.Len(), Equals, 27)
38 c.Assert(buf.String(), Equals, "0009\x01DDDD0009\x02PPPP0009\x01DDDD")
39 }