aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/encoder_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-07-25 15:00:01 +0200
committerSantiago M. Mola <santi@mola.io>2017-07-27 15:33:14 +0200
commit87413ced43b02a41359ce7a1a07ab41aec6ee313 (patch)
tree07975422ab63bfbb13aefc1a2d53d757c7342848 /plumbing/format/packfile/encoder_test.go
parent3834038893d5cacb49e5f2786ad955d26f666546 (diff)
downloadgo-git-87413ced43b02a41359ce7a1a07ab41aec6ee313.tar.gz
storage: reuse deltas from packfiles
* plumbing: add DeltaObject interface for EncodedObjects that are deltas and hold additional information about them, such as the hash of the base object. * plumbing/storer: add DeltaObjectStorer interface for object storers that can return DeltaObject. Note that calls to EncodedObject will never return instances of DeltaObject. That requires explicit calls to DeltaObject. * storage/filesystem: implement DeltaObjectStorer interface. * plumbing/packfile: packfile encoder now supports reusing deltas that are already computed (e.g. from an existing packfile) if the storage implements DeltaObjectStorer. Reusing deltas boosts performance of packfile generation (e.g. on push).
Diffstat (limited to 'plumbing/format/packfile/encoder_test.go')
-rw-r--r--plumbing/format/packfile/encoder_test.go76
1 files changed, 0 insertions, 76 deletions
diff --git a/plumbing/format/packfile/encoder_test.go b/plumbing/format/packfile/encoder_test.go
index 551d7ec..b5b0c42 100644
--- a/plumbing/format/packfile/encoder_test.go
+++ b/plumbing/format/packfile/encoder_test.go
@@ -2,11 +2,9 @@ package packfile
import (
"bytes"
- "io"
"github.com/src-d/go-git-fixtures"
"gopkg.in/src-d/go-git.v4/plumbing"
- "gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/memory"
. "gopkg.in/check.v1"
@@ -88,80 +86,6 @@ func (s *EncoderSuite) TestHashNotFound(c *C) {
c.Assert(err, Equals, plumbing.ErrObjectNotFound)
}
-func (s *EncoderSuite) TestDecodeEncodeDecode(c *C) {
- fixtures.Basic().ByTag("packfile").Test(c, func(f *fixtures.Fixture) {
- pf := f.Packfile()
- ph := f.PackfileHash
- storage := memory.NewStorage()
- s.testDecodeEncodeDecode(c, pf, ph, storage)
- })
-}
-
-func (s *EncoderSuite) testDecodeEncodeDecode(c *C,
- pf io.ReadCloser,
- ph plumbing.Hash,
- storage storer.Storer) {
-
- defer func() {
- c.Assert(pf.Close(), IsNil)
- }()
-
- scanner := NewScanner(pf)
-
- d, err := NewDecoder(scanner, storage)
- c.Assert(err, IsNil)
-
- ch, err := d.Decode()
- c.Assert(err, IsNil)
- c.Assert(ch, Equals, ph)
-
- objIter, err := storage.IterEncodedObjects(plumbing.AnyObject)
- c.Assert(err, IsNil)
-
- expectedObjects := map[plumbing.Hash]bool{}
- var hashes []plumbing.Hash
- err = objIter.ForEach(func(o plumbing.EncodedObject) error {
- expectedObjects[o.Hash()] = true
- hashes = append(hashes, o.Hash())
- return err
-
- })
- c.Assert(err, IsNil)
-
- enc := NewEncoder(s.buf, storage, false)
- _, err = enc.Encode(hashes)
- c.Assert(err, IsNil)
-
- scanner = NewScanner(s.buf)
- storage = memory.NewStorage()
- d, err = NewDecoder(scanner, storage)
- c.Assert(err, IsNil)
- _, err = d.Decode()
- c.Assert(err, IsNil)
-
- objIter, err = storage.IterEncodedObjects(plumbing.AnyObject)
- c.Assert(err, IsNil)
- obtainedObjects := map[plumbing.Hash]bool{}
- err = objIter.ForEach(func(o plumbing.EncodedObject) error {
- obtainedObjects[o.Hash()] = true
- return nil
- })
- c.Assert(err, IsNil)
- c.Assert(obtainedObjects, DeepEquals, expectedObjects)
-
- for h := range obtainedObjects {
- if !expectedObjects[h] {
- c.Errorf("obtained unexpected object: %s", h)
- }
- }
-
- for h := range expectedObjects {
- if !obtainedObjects[h] {
- c.Errorf("missing object: %s", h)
- }
- }
-}
-
func (s *EncoderSuite) TestDecodeEncodeWithDeltaDecodeREF(c *C) {
s.enc = NewEncoder(s.buf, s.store, true)
s.simpleDeltaTest(c)