aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/storer/reference.go2
-rw-r--r--plumbing/storer/reference_test.go24
2 files changed, 25 insertions, 1 deletions
diff --git a/plumbing/storer/reference.go b/plumbing/storer/reference.go
index 692fe88..6c2de0d 100644
--- a/plumbing/storer/reference.go
+++ b/plumbing/storer/reference.go
@@ -70,7 +70,7 @@ func (iter *ReferenceSliceIter) ForEach(cb func(*plumbing.Reference) error) erro
return nil
}
- return nil
+ return err
}
}
diff --git a/plumbing/storer/reference_test.go b/plumbing/storer/reference_test.go
index f698820..ff7bd68 100644
--- a/plumbing/storer/reference_test.go
+++ b/plumbing/storer/reference_test.go
@@ -1,6 +1,7 @@
package storer
import (
+ "errors"
"io"
. "gopkg.in/check.v1"
@@ -48,6 +49,29 @@ func (s *ReferenceSuite) TestReferenceSliceIterForEach(c *C) {
c.Assert(count, Equals, 2)
}
+func (s *ReferenceSuite) TestReferenceSliceIterForEachError(c *C) {
+ slice := []*plumbing.Reference{
+ plumbing.NewReferenceFromStrings("foo", "foo"),
+ plumbing.NewReferenceFromStrings("bar", "bar"),
+ }
+
+ i := NewReferenceSliceIter(slice)
+ var count int
+ exampleErr := errors.New("SOME ERROR")
+ err := i.ForEach(func(r *plumbing.Reference) error {
+ c.Assert(r == slice[count], Equals, true)
+ count++
+ if count == 2 {
+ return exampleErr
+ }
+
+ return nil
+ })
+
+ c.Assert(err, Equals, exampleErr)
+ c.Assert(count, Equals, 2)
+}
+
func (s *ReferenceSuite) TestReferenceSliceIterForEachStop(c *C) {
slice := []*plumbing.Reference{
plumbing.NewReferenceFromStrings("foo", "foo"),