From 0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Wed, 14 Dec 2016 23:12:44 +0100 Subject: move plumbing from top level package to plumbing (#183) * plumbing: rename Object -> EncodedObject. * plumbing/storer: rename ObjectStorer -> EncodedObjectStorer. * move difftree to plumbing/difftree. * move diff -> utils/diff * make Object/Tag/Blob/Tree/Commit/File depend on storer. * Object and its implementations now depend only on storer.EncodedObjectStorer, not git.Repository. * Tests are decoupled accordingly. * move Object/Commit/File/Tag/Tree to plumbing/object. * move Object/Commit/File/Tag/Tree to plumbing/object. * move checkClose to utils/ioutil. * move RevListObjects to plumbing/revlist.Objects. * move DiffTree to plumbing/difftree package. * rename files with plural nouns to singular * plumbing/object: add GetBlob/GetCommit/GetTag/GetTree. --- plumbing/format/packfile/encoder_test.go | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'plumbing/format/packfile/encoder_test.go') diff --git a/plumbing/format/packfile/encoder_test.go b/plumbing/format/packfile/encoder_test.go index b07e2f4..1a94d16 100644 --- a/plumbing/format/packfile/encoder_test.go +++ b/plumbing/format/packfile/encoder_test.go @@ -44,7 +44,7 @@ func (s *EncoderSuite) TestCorrectPackWithOneEmptyObject(c *C) { o := &plumbing.MemoryObject{} o.SetType(plumbing.CommitObject) o.SetSize(0) - _, err := s.store.SetObject(o) + _, err := s.store.SetEncodedObject(o) c.Assert(err, IsNil) hash, err := s.enc.Encode([]plumbing.Hash{o.Hash()}) @@ -69,10 +69,10 @@ func (s *EncoderSuite) TestCorrectPackWithOneEmptyObject(c *C) { } func (s *EncoderSuite) TestMaxObjectSize(c *C) { - o := s.store.NewObject() + o := s.store.NewEncodedObject() o.SetSize(9223372036854775807) o.SetType(plumbing.CommitObject) - _, err := s.store.SetObject(o) + _, err := s.store.SetEncodedObject(o) c.Assert(err, IsNil) hash, err := s.enc.Encode([]plumbing.Hash{o.Hash()}) c.Assert(err, IsNil) @@ -98,14 +98,14 @@ func (s *EncoderSuite) TestDecodeEncodeDecode(c *C) { c.Assert(err, IsNil) c.Assert(ch, Equals, f.PackfileHash) - objIter, err := d.o.IterObjects(plumbing.AnyObject) + objIter, err := d.o.IterEncodedObjects(plumbing.AnyObject) c.Assert(err, IsNil) - objects := []plumbing.Object{} + objects := []plumbing.EncodedObject{} hashes := []plumbing.Hash{} - err = objIter.ForEach(func(o plumbing.Object) error { + err = objIter.ForEach(func(o plumbing.EncodedObject) error { objects = append(objects, o) - hash, err := s.store.SetObject(o) + hash, err := s.store.SetEncodedObject(o) c.Assert(err, IsNil) hashes = append(hashes, hash) @@ -124,10 +124,10 @@ func (s *EncoderSuite) TestDecodeEncodeDecode(c *C) { _, err = d.Decode() c.Assert(err, IsNil) - objIter, err = d.o.IterObjects(plumbing.AnyObject) + objIter, err = d.o.IterEncodedObjects(plumbing.AnyObject) c.Assert(err, IsNil) - obtainedObjects := []plumbing.Object{} - err = objIter.ForEach(func(o plumbing.Object) error { + obtainedObjects := []plumbing.EncodedObject{} + err = objIter.ForEach(func(o plumbing.EncodedObject) error { obtainedObjects = append(obtainedObjects, o) return nil @@ -187,11 +187,11 @@ func (s *EncoderSuite) simpleDeltaTest(c *C, t plumbing.ObjectType) { _, err = d.Decode() c.Assert(err, IsNil) - decSrc, err := storage.Object(srcObject.Type(), srcObject.Hash()) + decSrc, err := storage.EncodedObject(srcObject.Type(), srcObject.Hash()) c.Assert(err, IsNil) c.Assert(decSrc, DeepEquals, srcObject) - decTarget, err := storage.Object(targetObject.Type(), targetObject.Hash()) + decTarget, err := storage.EncodedObject(targetObject.Type(), targetObject.Hash()) c.Assert(err, IsNil) c.Assert(decTarget, DeepEquals, targetObject) } @@ -226,20 +226,20 @@ func (s *EncoderSuite) deltaOverDeltaTest(c *C, t plumbing.ObjectType) { _, err = d.Decode() c.Assert(err, IsNil) - decSrc, err := storage.Object(srcObject.Type(), srcObject.Hash()) + decSrc, err := storage.EncodedObject(srcObject.Type(), srcObject.Hash()) c.Assert(err, IsNil) c.Assert(decSrc, DeepEquals, srcObject) - decTarget, err := storage.Object(targetObject.Type(), targetObject.Hash()) + decTarget, err := storage.EncodedObject(targetObject.Type(), targetObject.Hash()) c.Assert(err, IsNil) c.Assert(decTarget, DeepEquals, targetObject) - decOtherTarget, err := storage.Object(otherTargetObject.Type(), otherTargetObject.Hash()) + decOtherTarget, err := storage.EncodedObject(otherTargetObject.Type(), otherTargetObject.Hash()) c.Assert(err, IsNil) c.Assert(decOtherTarget, DeepEquals, otherTargetObject) } -func delta(base, target plumbing.Object, t plumbing.ObjectType) (plumbing.Object, error) { +func delta(base, target plumbing.EncodedObject, t plumbing.ObjectType) (plumbing.EncodedObject, error) { switch t { case plumbing.OFSDeltaObject: return GetOFSDelta(base, target) @@ -250,7 +250,7 @@ func delta(base, target plumbing.Object, t plumbing.ObjectType) (plumbing.Object } } -func newObject(t plumbing.ObjectType, cont []byte) plumbing.Object { +func newObject(t plumbing.ObjectType, cont []byte) plumbing.EncodedObject { o := plumbing.MemoryObject{} o.SetType(t) o.SetSize(int64(len(cont))) -- cgit