diff options
Diffstat (limited to 'common_test.go')
-rw-r--r-- | common_test.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/common_test.go b/common_test.go index 53160a7..edc41a9 100644 --- a/common_test.go +++ b/common_test.go @@ -1,7 +1,9 @@ package git import ( + "bytes" "io" + "io/ioutil" "os" "testing" @@ -29,21 +31,22 @@ func (s *MockGitUploadPackService) ConnectWithAuth(url common.Endpoint, auth com } func (s *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) { - hash := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + h := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5") - cap := common.NewCapabilities() - cap.Decode("6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEADmulti_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2:2.4.8~dbussink-fix-enterprise-tokens-compilation-1167-gc7006cf") + c := common.NewCapabilities() + c.Decode("6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEADmulti_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2:2.4.8~dbussink-fix-enterprise-tokens-compilation-1167-gc7006cf") return &common.GitUploadPackInfo{ - Capabilities: cap, - Head: hash, - Refs: map[string]core.Hash{"refs/heads/master": hash}, + Capabilities: c, + Head: h, + Refs: map[string]core.Hash{"refs/heads/master": h}, }, nil } func (s *MockGitUploadPackService) Fetch(*common.GitUploadPackRequest) (io.ReadCloser, error) { var err error s.RC, err = os.Open("formats/packfile/fixtures/git-fixture.ref-delta") + return s.RC, err } @@ -65,20 +68,28 @@ func unpackFixtures(c *C, fixtures ...[]packedFixture) map[string]*Repository { if _, existing := repos[fixture.url]; existing { continue } - repos[fixture.url] = NewPlainRepository() - d, err := os.Open(fixture.packfile) - c.Assert(err, IsNil) + comment := Commentf("fixture packfile: %q", fixture.packfile) - r := packfile.NewReader(d) - r.Format = packfile.OFSDeltaFormat // This is hardcoded because we don't have a good way to sniff the format + repos[fixture.url] = NewPlainRepository() - _, err = r.Read(repos[fixture.url].Storage) + f, err := os.Open(fixture.packfile) + c.Assert(err, IsNil, comment) + + // increase memory consumption to speed up tests + data, err := ioutil.ReadAll(f) c.Assert(err, IsNil) + memStream := bytes.NewReader(data) + r := packfile.NewStream(memStream) + + d := packfile.NewDecoder(r) + err = d.Decode(repos[fixture.url].Storage) + c.Assert(err, IsNil, comment) - c.Assert(d.Close(), IsNil) + c.Assert(f.Close(), IsNil, comment) } } + return repos } |