diff options
author | Santiago M. Mola <santi@mola.io> | 2016-12-14 23:12:44 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-14 23:12:44 +0100 |
commit | 0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 (patch) | |
tree | 49e81e74e82d84fd88b2fc1e4b0dc7c7bfe9c40f /plumbing/storer/object_test.go | |
parent | df0f38af83f972f026d7e14150f3d37b95f13484 (diff) | |
download | go-git-0af572dd21c0aa79d13745b633ee24ba6c4d6cf1.tar.gz |
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.
Diffstat (limited to 'plumbing/storer/object_test.go')
-rw-r--r-- | plumbing/storer/object_test.go | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/plumbing/storer/object_test.go b/plumbing/storer/object_test.go index a0a7755..6bdd25c 100644 --- a/plumbing/storer/object_test.go +++ b/plumbing/storer/object_test.go @@ -11,14 +11,14 @@ import ( func Test(t *testing.T) { TestingT(t) } type ObjectSuite struct { - Objects []plumbing.Object + Objects []plumbing.EncodedObject Hash []plumbing.Hash } var _ = Suite(&ObjectSuite{}) func (s *ObjectSuite) SetUpSuite(c *C) { - s.Objects = []plumbing.Object{ + s.Objects = []plumbing.EncodedObject{ s.buildObject([]byte("foo")), s.buildObject([]byte("bar")), } @@ -29,7 +29,7 @@ func (s *ObjectSuite) SetUpSuite(c *C) { } func (s *ObjectSuite) TestMultiObjectIterNext(c *C) { - expected := []plumbing.Object{ + expected := []plumbing.EncodedObject{ &plumbing.MemoryObject{}, &plumbing.MemoryObject{}, &plumbing.MemoryObject{}, @@ -38,14 +38,14 @@ func (s *ObjectSuite) TestMultiObjectIterNext(c *C) { &plumbing.MemoryObject{}, } - iter := NewMultiObjectIter([]ObjectIter{ - NewObjectSliceIter(expected[0:2]), - NewObjectSliceIter(expected[2:4]), - NewObjectSliceIter(expected[4:5]), + iter := NewMultiEncodedObjectIter([]EncodedObjectIter{ + NewEncodedObjectSliceIter(expected[0:2]), + NewEncodedObjectSliceIter(expected[2:4]), + NewEncodedObjectSliceIter(expected[4:5]), }) var i int - iter.ForEach(func(o plumbing.Object) error { + iter.ForEach(func(o plumbing.EncodedObject) error { c.Assert(o, Equals, expected[i]) i++ return nil @@ -54,7 +54,7 @@ func (s *ObjectSuite) TestMultiObjectIterNext(c *C) { iter.Close() } -func (s *ObjectSuite) buildObject(content []byte) plumbing.Object { +func (s *ObjectSuite) buildObject(content []byte) plumbing.EncodedObject { o := &plumbing.MemoryObject{} o.Write(content) @@ -65,8 +65,8 @@ func (s *ObjectSuite) TestObjectLookupIter(c *C) { var count int storage := &MockObjectStorage{s.Objects} - i := NewObjectLookupIter(storage, plumbing.CommitObject, s.Hash) - err := i.ForEach(func(o plumbing.Object) error { + i := NewEncodedObjectLookupIter(storage, plumbing.CommitObject, s.Hash) + err := i.ForEach(func(o plumbing.EncodedObject) error { c.Assert(o, NotNil) c.Assert(o.Hash().String(), Equals, s.Hash[count].String()) count++ @@ -80,8 +80,8 @@ func (s *ObjectSuite) TestObjectLookupIter(c *C) { func (s *ObjectSuite) TestObjectSliceIter(c *C) { var count int - i := NewObjectSliceIter(s.Objects) - err := i.ForEach(func(o plumbing.Object) error { + i := NewEncodedObjectSliceIter(s.Objects) + err := i.ForEach(func(o plumbing.EncodedObject) error { c.Assert(o, NotNil) c.Assert(o.Hash().String(), Equals, s.Hash[count].String()) count++ @@ -94,10 +94,10 @@ func (s *ObjectSuite) TestObjectSliceIter(c *C) { } func (s *ObjectSuite) TestObjectSliceIterStop(c *C) { - i := NewObjectSliceIter(s.Objects) + i := NewEncodedObjectSliceIter(s.Objects) var count = 0 - err := i.ForEach(func(o plumbing.Object) error { + err := i.ForEach(func(o plumbing.EncodedObject) error { c.Assert(o, NotNil) c.Assert(o.Hash().String(), Equals, s.Hash[count].String()) count++ @@ -109,11 +109,11 @@ func (s *ObjectSuite) TestObjectSliceIterStop(c *C) { } func (s *ObjectSuite) TestObjectSliceIterError(c *C) { - i := NewObjectSliceIter([]plumbing.Object{ + i := NewEncodedObjectSliceIter([]plumbing.EncodedObject{ s.buildObject([]byte("foo")), }) - err := i.ForEach(func(plumbing.Object) error { + err := i.ForEach(func(plumbing.EncodedObject) error { return fmt.Errorf("a random error") }) @@ -121,18 +121,18 @@ func (s *ObjectSuite) TestObjectSliceIterError(c *C) { } type MockObjectStorage struct { - db []plumbing.Object + db []plumbing.EncodedObject } -func (o *MockObjectStorage) NewObject() plumbing.Object { +func (o *MockObjectStorage) NewEncodedObject() plumbing.EncodedObject { return nil } -func (o *MockObjectStorage) SetObject(obj plumbing.Object) (plumbing.Hash, error) { +func (o *MockObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error) { return plumbing.ZeroHash, nil } -func (o *MockObjectStorage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) { +func (o *MockObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) { for _, o := range o.db { if o.Hash() == h { return o, nil @@ -141,7 +141,7 @@ func (o *MockObjectStorage) Object(t plumbing.ObjectType, h plumbing.Hash) (plum return nil, plumbing.ErrObjectNotFound } -func (o *MockObjectStorage) IterObjects(t plumbing.ObjectType) (ObjectIter, error) { +func (o *MockObjectStorage) IterEncodedObjects(t plumbing.ObjectType) (EncodedObjectIter, error) { return nil, nil } |