aboutsummaryrefslogtreecommitdiffstats
path: root/common_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-02-20 00:45:00 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-02-20 00:45:00 +0100
commit9c319b2c4d6bb5cff43d237583b463619e95dc93 (patch)
treeb32c906cef4779c9cec73749400e1a48eff10bf5 /common_test.go
parentffe26fecc9b1435054d851ef93f156536f2a4584 (diff)
parent916755f7652d4a3189aa717c7f2668c9aa0b1373 (diff)
downloadgo-git-9c319b2c4d6bb5cff43d237583b463619e95dc93.tar.gz
Merge pull request #32 from scjalliance/annotated-tags
Annotated tags
Diffstat (limited to 'common_test.go')
-rw-r--r--common_test.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/common_test.go b/common_test.go
index 0cd61f1..53160a7 100644
--- a/common_test.go
+++ b/common_test.go
@@ -7,6 +7,7 @@ import (
"gopkg.in/src-d/go-git.v3/clients/common"
"gopkg.in/src-d/go-git.v3/core"
+ "gopkg.in/src-d/go-git.v3/formats/packfile"
. "gopkg.in/check.v1"
)
@@ -46,15 +47,41 @@ func (s *MockGitUploadPackService) Fetch(*common.GitUploadPackRequest) (io.ReadC
return s.RC, err
}
-var fixtureRepos = [...]struct {
+type packedFixture struct {
url string
packfile string
-}{
+}
+
+var fixtureRepos = []packedFixture{
{"https://github.com/tyba/git-fixture.git", "formats/packfile/fixtures/git-fixture.ofs-delta"},
{"https://github.com/jamesob/desk.git", "formats/packfile/fixtures/jamesob-desk.pack"},
{"https://github.com/spinnaker/spinnaker.git", "formats/packfile/fixtures/spinnaker-spinnaker.pack"},
}
+func unpackFixtures(c *C, fixtures ...[]packedFixture) map[string]*Repository {
+ repos := make(map[string]*Repository, 0)
+ for _, group := range fixtures {
+ for _, fixture := range group {
+ if _, existing := repos[fixture.url]; existing {
+ continue
+ }
+ repos[fixture.url] = NewPlainRepository()
+
+ d, err := os.Open(fixture.packfile)
+ c.Assert(err, IsNil)
+
+ r := packfile.NewReader(d)
+ r.Format = packfile.OFSDeltaFormat // This is hardcoded because we don't have a good way to sniff the format
+
+ _, err = r.Read(repos[fixture.url].Storage)
+ c.Assert(err, IsNil)
+
+ c.Assert(d.Close(), IsNil)
+ }
+ }
+ return repos
+}
+
type SuiteCommon struct{}
var _ = Suite(&SuiteCommon{})