aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/uppackreq_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-12-05 15:44:50 +0100
committerGitHub <noreply@github.com>2016-12-05 15:44:50 +0100
commit11735c3b3aaa8f789dc10739a4de7ad438196000 (patch)
treec83fa6ddf9748fd0e4e4edb4d0e2692994145ace /plumbing/protocol/packp/uppackreq_test.go
parent0042bb031676a20ffc789f94e332a6da70e2756d (diff)
downloadgo-git-11735c3b3aaa8f789dc10739a4de7ad438196000.tar.gz
plumbing/protocol: paktp avoid duplication of haves, wants and shallow (#158)
Diffstat (limited to 'plumbing/protocol/packp/uppackreq_test.go')
-rw-r--r--plumbing/protocol/packp/uppackreq_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/uppackreq_test.go b/plumbing/protocol/packp/uppackreq_test.go
index 75b75b4..e551f45 100644
--- a/plumbing/protocol/packp/uppackreq_test.go
+++ b/plumbing/protocol/packp/uppackreq_test.go
@@ -4,6 +4,8 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/capability"
+ "bytes"
+
. "gopkg.in/check.v1"
)
@@ -40,3 +42,28 @@ func (s *UploadPackRequestSuite) TestIsEmpty(c *C) {
c.Assert(r.IsEmpty(), Equals, true)
}
+
+type UploadHavesSuite struct{}
+
+var _ = Suite(&UploadHavesSuite{})
+
+func (s *UploadHavesSuite) TestEncode(c *C) {
+ uh := &UploadHaves{}
+ uh.Haves = append(uh.Haves,
+ plumbing.NewHash("1111111111111111111111111111111111111111"),
+ plumbing.NewHash("3333333333333333333333333333333333333333"),
+ plumbing.NewHash("1111111111111111111111111111111111111111"),
+ plumbing.NewHash("2222222222222222222222222222222222222222"),
+ plumbing.NewHash("1111111111111111111111111111111111111111"),
+ )
+
+ buf := bytes.NewBuffer(nil)
+ err := uh.Encode(buf)
+ c.Assert(err, IsNil)
+ c.Assert(buf.String(), Equals, ""+
+ "0032have 1111111111111111111111111111111111111111\n"+
+ "0032have 2222222222222222222222222222222222222222\n"+
+ "0032have 3333333333333333333333333333333333333333\n"+
+ "0000",
+ )
+}