diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-23 16:18:54 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-23 16:18:54 +0200 |
commit | 11a24261b21f5f0e9e8304bcbb4a0b27ff5cbbb5 (patch) | |
tree | a9980da45676fd307cfc9ad5fd222d049909b34d | |
parent | a8c0b15da2f628efb304bc1d9aa79b49144f98a1 (diff) | |
download | go-git-11a24261b21f5f0e9e8304bcbb4a0b27ff5cbbb5.tar.gz |
fix tag iter test
-rw-r--r-- | core/object.go | 2 | ||||
-rw-r--r-- | core/object_test.go | 18 | ||||
-rw-r--r-- | tag_test.go | 8 |
3 files changed, 25 insertions, 3 deletions
diff --git a/core/object.go b/core/object.go index 06137d2..30beff8 100644 --- a/core/object.go +++ b/core/object.go @@ -274,7 +274,7 @@ func ForEachIterator(iter bareIterator, cb func(Object) error) error { return nil } - return nil + return err } } } diff --git a/core/object_test.go b/core/object_test.go index 08c5dd2..d087aae 100644 --- a/core/object_test.go +++ b/core/object_test.go @@ -1,6 +1,10 @@ package core -import . "gopkg.in/check.v1" +import ( + "fmt" + + . "gopkg.in/check.v1" +) type ObjectSuite struct{} @@ -137,6 +141,18 @@ func (s *ObjectSuite) TestObjectSliceIterStop(c *C) { c.Assert(err, IsNil) } +func (s *ObjectSuite) TestObjectSliceIterError(c *C) { + i := NewObjectSliceIter([]Object{ + &MemoryObject{h: NewHash("4921e391f1128010a2d957f8db15c5e729ccf94a")}, + }) + + err := i.ForEach(func(Object) error { + return fmt.Errorf("a random error") + }) + + c.Assert(err, NotNil) +} + type MockObjectStorage struct{} func (o *MockObjectStorage) NewObject() Object { diff --git a/tag_test.go b/tag_test.go index 180518a..5957678 100644 --- a/tag_test.go +++ b/tag_test.go @@ -127,8 +127,14 @@ func (s *TagSuite) TestTagItter(c *C) { c.Assert(err, IsNil) c.Assert(count, Equals, 4) +} + +func (s *TagSuite) TestTagIterError(c *C) { + r := s.Repositories["https://github.com/git-fixtures/tags.git"] + iter, err := r.s.ObjectStorage().Iter(core.TagObject) + c.Assert(err, IsNil) - i = NewTagIter(r, iter) + i := NewTagIter(r, iter) err = i.ForEach(func(t *Tag) error { return fmt.Errorf("a random error") }) |