aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/updreq_encode_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-09 14:44:03 +0100
committerGitHub <noreply@github.com>2016-12-09 14:44:03 +0100
commit0e1a52757a3938e97cf7d31e0dff3c9949001763 (patch)
tree8b998fdc3eaaf6b2d6c69a125759a778664207a5 /plumbing/protocol/packp/updreq_encode_test.go
parent4f16cc925238aae81586e917d26b8ff6b6a340bd (diff)
downloadgo-git-0e1a52757a3938e97cf7d31e0dff3c9949001763.tar.gz
transport: add git-send-pack support to local/ssh. (#163)
* protocol/packp: add Packfile field to ReferenceUpdateRequest. * protocol/packp: add NewReferenceUpdateRequestFromCapabilities. * NewReferenceUpdateRequestFromCapabilities can be used to create a ReferenceUpdateRequest with initial capabilities compatible with the server. * protocol/packp: fix new line handling on report status. * transport/file: test error on unexisting command.
Diffstat (limited to 'plumbing/protocol/packp/updreq_encode_test.go')
-rw-r--r--plumbing/protocol/packp/updreq_encode_test.go25
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)
+}