aboutsummaryrefslogtreecommitdiffstats
path: root/clients/common/common_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-10-23 02:26:15 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2015-10-23 02:26:15 +0200
commite1d8866ffa78fa16d2f39b0ba5344a7269ee5371 (patch)
tree4602b0ca341187aad77048f807cde423af410554 /clients/common/common_test.go
parent2275fa7d0c75d20103f90b0e1616937d5a9fc5e6 (diff)
downloadgo-git-e1d8866ffa78fa16d2f39b0ba5344a7269ee5371.tar.gz
clients and remote: fetch implementation
Diffstat (limited to 'clients/common/common_test.go')
-rw-r--r--clients/common/common_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/clients/common/common_test.go b/clients/common/common_test.go
index 0b9b60a..37d4ff9 100644
--- a/clients/common/common_test.go
+++ b/clients/common/common_test.go
@@ -1,9 +1,12 @@
package common
import (
+ "bytes"
+ "encoding/base64"
"testing"
. "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git.v2/pktline"
)
func Test(t *testing.T) { TestingT(t) }
@@ -35,3 +38,25 @@ func (s *SuiteCommon) TestCapabilitiesSymbolicReference(c *C) {
cap := parseCapabilities(CapabilitiesFixture)
c.Assert(cap.SymbolicReference("HEAD"), Equals, "refs/heads/master")
}
+
+const GitUploadPackInfoFixture = "MDAxZSMgc2VydmljZT1naXQtdXBsb2FkLXBhY2sKMDAwMDAxMGM2ZWNmMGVmMmMyZGZmYjc5NjAzM2U1YTAyMjE5YWY4NmVjNjU4NGU1IEhFQUQAbXVsdGlfYWNrIHRoaW4tcGFjayBzaWRlLWJhbmQgc2lkZS1iYW5kLTY0ayBvZnMtZGVsdGEgc2hhbGxvdyBuby1wcm9ncmVzcyBpbmNsdWRlLXRhZyBtdWx0aV9hY2tfZGV0YWlsZWQgbm8tZG9uZSBzeW1yZWY9SEVBRDpyZWZzL2hlYWRzL21hc3RlciBhZ2VudD1naXQvMjoyLjQuOH5kYnVzc2luay1maXgtZW50ZXJwcmlzZS10b2tlbnMtY29tcGlsYXRpb24tMTE2Ny1nYzcwMDZjZgowMDNmZThkM2ZmYWI1NTI4OTVjMTliOWZjZjdhYTI2NGQyNzdjZGUzMzg4MSByZWZzL2hlYWRzL2JyYW5jaAowMDNmNmVjZjBlZjJjMmRmZmI3OTYwMzNlNWEwMjIxOWFmODZlYzY1ODRlNSByZWZzL2hlYWRzL21hc3RlcgowMDNlYjhlNDcxZjU4YmNiY2E2M2IwN2JkYTIwZTQyODE5MDQwOWMyZGI0NyByZWZzL3B1bGwvMS9oZWFkCjAwMDA="
+
+func (s *SuiteCommon) TestGitUploadPackInfo(c *C) {
+ b, _ := base64.StdEncoding.DecodeString(GitUploadPackInfoFixture)
+ info, err := NewGitUploadPackInfo(pktline.NewDecoder(bytes.NewBuffer(b)))
+ c.Assert(err, IsNil)
+
+ ref := info.Capabilities.SymbolicReference("HEAD")
+ c.Assert(ref, Equals, "refs/heads/master")
+ c.Assert(info.Refs[ref].Id, Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ c.Assert(info.Refs[ref].Name, Equals, "refs/heads/master")
+}
+
+func (s *SuiteCommon) TestGitUploadPackRequest(c *C) {
+ r := &GitUploadPackRequest{
+ Want: []string{"foo", "qux"},
+ Have: []string{"bar"},
+ }
+
+ c.Assert(r.String(), Equals, "000dwant foo\n000dwant qux\n000dhave bar\n00000009done\n")
+}