diff options
Diffstat (limited to 'plumbing/protocol/packp/updreq_encode_test.go')
-rw-r--r-- | plumbing/protocol/packp/updreq_encode_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/updreq_encode_test.go b/plumbing/protocol/packp/updreq_encode_test.go index 47958fd..14f9975 100644 --- a/plumbing/protocol/packp/updreq_encode_test.go +++ b/plumbing/protocol/packp/updreq_encode_test.go @@ -7,6 +7,7 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/format/pktline" . "gopkg.in/check.v1" + "io/ioutil" ) type UpdReqEncodeSuite struct{} @@ -117,3 +118,27 @@ func (s *UpdReqEncodeSuite) TestMultipleCommandsAndCapabilitiesShallow(c *C) { s.testEncode(c, r, expected) } + +func (s *UpdReqEncodeSuite) TestWithPackfile(c *C) { + hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5") + hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5") + name := "myref" + + packfileContent := []byte("PACKabc") + packfileReader := bytes.NewReader(packfileContent) + packfileReadCloser := ioutil.NopCloser(packfileReader) + + r := NewReferenceUpdateRequest() + r.Commands = []*Command{ + {Name: name, Old: hash1, New: hash2}, + } + r.Packfile = packfileReadCloser + + expected := pktlines(c, + "1ecf0ef2c2dffb796033e5a02219af86ec6584e5 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref\x00", + pktline.FlushString, + ) + expected = append(expected, packfileContent...) + + s.testEncode(c, r, expected) +} |